Metadata-Version: 2.1
Name: flake8-pep585
Version: 0.1.5.1
Summary: flake8 plugin to enforce new-style type hints (PEP 585)
Home-page: https://github.com/decorator-factory/flake8-pep585
License: MPL-2.0
Author: decorator-factory
Author-email: decorator-factory@yandex.ru
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.9
Project-URL: Repository, https://github.com/decorator-factory/flake8-pep585
Description-Content-Type: text/markdown

# flake8-pep585

This plugin enforces the changes proposed by [PEP 585](https://peps.python.org/pep-0585/).

## What does PEP 585 change?

Before PEP 585, you had to import stuff from `typing` to annotate some objects from the standard library:

- For context managers, you'd import `typing.ContextManager`
- For lists, you'd import `typing.List`
- For callables, you'd import `typing.Callable`
- ...and so on

With PEP 585, you can now use classes already present in the standard library. For example:
- For a context manager giving an `int`, use `contextlib.AbstractContextManager[int]`
- For a `list` of `dict`s mapping `str`s to `int`s, use `list[dict[str, int]]`
- For a callable taking a `float` and returning an `int`, use `collections.abc.Callable[[float], int]`

`typing.List`, `typing.Callable` etc. are now deprecated. This is pretty hard to discover, since these
imports don't cause a deprecation warning. IDEs don't help either: the "auto-import" feature often suggests
importing a deprecated item.

This plugin lets you find these deprecated imports.

## Examples

### Direct import
```py
from typing import Callable
```
```
PEA001 typing.Callable is deprecated, use collections.abc.Callable instead. See PEP 585 for details
```

### Qualified import
```py
from datetime import time
import typing as ty

def construct_time(match: ty.Match) -> time:
    return time(
        hour=int(match["hour"]),
        minute=int(match["minute"]),
    )
```
```
PEA001 typing.Match is deprecated, use re.Match instead. See PEP 585 for details
```

# Installation

1. Make sure you have `flake8` installed
2. Run `pip install flake8-pep585`
3. Run `flake8` on your code

