Features:
- Support Python 3.12
- Support PEP 695 syntax for declaring type aliases
- Correctly emit Y019 errors for PEP-695 methods that are generic around a
TypeVar
instead of returningtyping_extensions.Self
- Introduce Y057: Do not use
typing.ByteString
orcollections.abc.ByteString
. These types have unclear semantics, and are deprecated; usetyping_extensions.Buffer
or a union such asbytes | bytearray | memoryview
instead. See PEP 688 for more details. - The way in which flake8-pyi modifies pyflakes runs has been improved:
-
When flake8-pyi is installed, pyflakes will now complain about forward references in default values for function and method parameters (the same as pyflakes does when it checks
.py
files). Unlike in.py
files, forward references in default values are legal in stub files. However, they are never necessary, and are considered bad style. (Forward references for parameter annotations are still allowed.)Contributed by tomasr8.
-
When flake8-pyi is installed, pyflakes's F822 check now produces many fewer false positives when flake8 is run on
.pyi
files. It now understands thatx: int
in a stub file is sufficient forx
to be considered "bound", and that"x"
can therefore be included in__all__
.
-
Bugfixes:
- Y018, Y046, Y047 and Y049 previously failed to detect unused TypeVars/ParamSpecs/TypeAliases/TypedDicts/Protocols if the object in question had multiple definitions in the same file (e.g. across two branches of an
if sys.version_info >= (3, 10)
check). This bug has now been fixed. - Y020 was previously not emitted if quoted annotations were used in TypeVar constraints. This bug has now been fixed.
Other changes:
- flake8-pyi no longer supports being run on Python 3.7, which has reached its end of life.
- flake8-pyi no longer supports being run with flake8 <v6.