Bugfixes:
- Specify encoding when opening files. Prevents
UnicodeDecodeError
on Windows when the file contains non-CP1252 characters. Contributed by Avasam.
Other changes:
- Support running with flake8 v6.
Bugfixes:
- Do not emit Y020 for empty strings. Y020 concerns "quoted annotations", but an empty string can never be a quoted annotation.
- Add special-casing so that Y020 is not emitted for
__slots__
definitions insideclass
blocks. - Expand Y035 to cover
__slots__
definitions as well as__match_args__
and__all__
definitions. - Expand Y015 so that errors are emitted for assignments to negative numbers.
Other changes:
- Since v22.8.1, flake8-pyi has emitted a
FutureWarning
if run with flake8<5, warning that the plugin would soon become incompatible with flake8<5. Due to some issues that mean that some users are unable to upgrade to flake8>=5, however, flake8-pyi no longer intends to remove support for running the plugin with flake8<5 before Python 3.7 has reached end-of-life. As such, theFutureWarning
is no longer emitted.
New error codes:
- Y047: Detect unused
TypeAlias
declarations. - Y049: Detect unused
TypedDict
definitions. - Y050: Prefer
typing_extensions.Never
for argument annotations overtyping.NoReturn
. - Y051: Detect redundant unions between
Literal
types and builtin supertypes (e.g.Literal["foo"] | str
, orLiteral[5] | int
).
Other enhancements:
- Support
mypy_extensions.TypedDict
.
- Add support for flake8 >= 5.0.0.
New error codes:
- Y046: Detect unused
Protocol
s. - Y048: Function bodies should contain exactly one statement.
Bugfixes:
- Improve error message for the case where a function body contains a docstring
and a
...
orpass
statement.
Other changes:
- Pin required flake8 version to <5.0.0 (flake8-pyi is not currently compatible with flake8 5.0.0).
New error codes:
- Introduce Y041: Ban redundant numeric unions (
int | float
,int | complex
,float | complex
). - Introduce Y042: Type alias names should use CamelCase rather than snake_case
- Introduce Y043: Ban type aliases from having names ending with an uppercase "T".
- Introduce Y044: Discourage unnecessary
from __future__ import annotations
import. Contributed by Torsten Wörtwein. - Introduce Y045: Ban returning
(Async)Iterable
from__(a)iter__
methods.
Other enhancements and behaviour changes:
- Improve error message for Y026 check.
- Expand Y026 check. Since version 22.4.0, this has only emitted an error for
assignments to
typing.Literal
,typing.Union
, and PEP 604 unions. It now also emits an error for any subscription on the right-hand side of a simple assignment, as well as for assignments totyping.Any
andNone
. - Support
typing_extensions.overload
andtyping_extensions.NamedTuple
. - Slightly expand Y034 to cover the case where a class inheriting from
(Async)Iterator
returns(Async)Iterable
from__(a)iter__
. These classes should nearly always returnSelf
from these methods. - Support Python 3.11.
Behaviour changes:
- Relax Y020 check slightly, enabling the idiom
__all__ += ["foo", "bar"]
to be used in a stub file.
Features:
- Introduce Y039: Use
str
instead oftyping.Text
for Python 3 stubs. - Teach the Y036 check that
builtins.object
(as well as the unqualifiedobject
) is acceptable as an annotation for an__(a)exit__
method argument. - Teach the Y029 check to emit errors for
__repr__
and__str__
methods that returnbuiltins.str
(as opposed to the unqualifiedstr
). - Introduce Y040: Never explicitly inherit from
object
in Python 3 stubs.
Features:
- Expand Y027 check to prohibit importing any objects from the
typing
module that are aliases for objects livingcollections.abc
(except fortyping.AbstractSet
, which is special-cased). - Introduce Y038: Use
from collections.abc import Set as AbstractSet
instead offrom typing import AbstractSet
.
Bugfixes:
- Improve inaccurate error messages for Y036.
Features:
- Introduce Y036 (check for badly defined
__exit__
and__aexit__
methods). - Introduce Y037 (Use PEP 604 syntax instead of
typing.Union
andtyping.Optional
). Contributed by Oleg Höfling.
Behaviour changes:
- Expand Y035 to cover
__match_args__
inside class definitions, as well as__all__
in the global scope.
Bugfixes:
- Improve Y026 check (regarding
typing.TypeAlias
) to reduce false-positive errors emitted when the plugin encountered variable aliases in a stub file.
Bugfixes:
- fix bug where incorrect quoted annotations were not detected within
if
blocks
Behaviour changes:
- Add special-casing so that string literals are allowed in the context of
__match_args__
assignments inside a class definition. - Add special-casing so that arbitrary values can be assigned to a variable in
a stub file if the variable is annotated with
Final
.
Bugfixes:
- fix bugs in several error codes so that e.g.
_T = typing.TypeVar("_T")
is recognised as aTypeVar
definition (previously only_T = TypeVar("_T")
was recognised). - fix bug where
foo = False
at the module level did not trigger a Y015 error. - fix bug where
TypeVar
s were erroneously flagged as unused if they were only used in atyping.Union
subscript. - improve unclear error messages for Y022, Y023 and Y027 error codes.
Features:
- introduce Y032 (prefer
object
toAny
for the second argument in__eq__
and__ne__
methods). - introduce Y033 (always use annotations in stubs, rather than type comments).
- introduce Y034 (detect common errors where return types are hardcoded, but they
should use
TypeVar
s instead). - introduce Y035 (
__all__
in a stub has the same semantics as at runtime).
- extend Y001 to cover
ParamSpec
andTypeVarTuple
in addition toTypeVar
- detect usage of non-integer indices in
sys.version_info
checks - extend Y010 to check async functions in addition to normal functions
- extend Y010 to cover what was previously included in Y090 (disallow
assignments in
__init__
methods) and Y091 (disallowraise
statements). The previous checks were disabled by default. - introduce Y016 (duplicate union member)
- introduce Y017 (disallows assignments with multiple targets or non-name targets)
- introduce Y018 (detect unused
TypeVar
s) - introduce Y019 (detect
TypeVar
s that should be_typeshed.Self
, but aren't) - introduce Y020 (never use quoted annotations in stubs)
- introduce Y021 (docstrings should not be included in stubs)
- introduce Y022 (prefer stdlib classes over
typing
aliases) - introduce Y023 (prefer
typing
overtyping_extensions
) - introduce Y024 (prefer
typing.NamedTuple
tocollections.namedtuple
) - introduce Y026 (require using
TypeAlias
for type aliases) - introduce Y025 (always alias
collections.abc.Set
) - introduce Y027 (Python 2-incompatible extension of Y022)
- introduce Y028 (Use class-based syntax for
NamedTuple
s) - introduce Y029 (never define
__repr__
or__str__
) - introduce Y030 (use
Literal['foo', 'bar']
instead ofLiteral['foo'] | Literal['bar']
) - introduce Y031 (use class-based syntax for
TypedDict
s where possible) - all errors are now enabled by default
- remove Y092 (top-level attribute must not have a default value)
attrs
is no longer a dependencyast_decompiler
has been added as a dependency on Python 3.8 and 3.7- support Python 3.10
- discontinue support for Python 3.6
- support Python 3.9
- support flake8 3.8.0
- introduce Y091 (function body must not contain
raise
) - introduce Y015 (attribute must not have a default value other than
...
) - introduce Y092 (top-level attribute must not have a default value)
- update pyflakes dependency
- support Python 3.7
- add a check for non-ellipsis, non-typed arguments
- add checks for checking empty classes
- use --stdin-display-name as the filename when reading from stdin
- introduce Y011
- (release herp derp, don't use)
- introduce Y001 - Y010
- introduce optional Y090
- handle
del
statements in stub files
- handle annotated assignments in 3.6+ with forward reference support
-
handle forward references during subclassing on module level
-
handle forward references during type aliasing assignments on module level
-
first published version
-
date-versioned