Skip to content

Releases: PyCQA/flake8-pyi

22.8.2

31 Aug 10:51
60a3112
Compare
Choose a tag to compare

New error codes:

  • Y047: Detect unused TypeAlias declarations.
  • Y049: Detect unused TypedDict definitions.
  • Y050: Prefer typing_extensions.Never for argument annotations over
    typing.NoReturn.
  • Y051: Detect redundant unions between Literal types and builtin supertypes
    (e.g. Literal["foo"] | str, or Literal[5] | int).

Other enhancements:

  • Support mypy_extensions.TypedDict.

22.8.1

02 Aug 19:14
dfe6d76
Compare
Choose a tag to compare
  • Add support for flake8 >= 5.0.0.

22.8.0

02 Aug 07:29
baa0ab5
Compare
Choose a tag to compare

New error codes:

  • Y046: Detect unused Protocols.
  • Y048: Function bodies should contain exactly one statement.

Bugfixes:

  • Improve error message for the case where a function body contains a docstring
    and a ... or pass statement.

Other changes:

  • Pin required flake8 version to <5.0.0 (flake8-pyi is not currently compatible with flake8 5.0.0).

22.7.0

24 Jul 02:11
c7a051a
Compare
Choose a tag to compare

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 to typing.Any and None.
  • Support typing_extensions.overload and typing_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 return
    Self from these methods.
  • Support Python 3.11.

22.5.1

19 May 16:49
d904916
Compare
Choose a tag to compare

Behaviour changes:

  • Relax Y020 check slightly, enabling the idiom __all__ += ["foo", "bar"] to be used
    in a stub file.

22.5.0

10 May 16:00
7489b3b
Compare
Choose a tag to compare

Features:

  • Introduce Y039: Use str instead of typing.Text for Python 3 stubs.
  • Teach the Y036 check that builtins.object (as well as the unqualified object) is acceptable as an annotation for an __(a)exit__ method argument.
  • Teach the Y029 check to emit errors for __repr__ and __str__ methods that return builtins.str (as opposed to the unqualified str).
  • Introduce Y040: Never explicitly inherit from object in Python 3 stubs.

22.4.1

18 Apr 21:45
25bb08b
Compare
Choose a tag to compare

Features:

  • Expand Y027 check to prohibit importing any objects from the typing module that are aliases for objects living in collections.abc (except for typing.AbstractSet, which is special-cased).
  • Introduce Y038: Use from collections.abc import Set as AbstractSet instead of from typing import AbstractSet.

Bugfixes:

  • Improve inaccurate error messages for Y036.

22.4.0

16 Apr 23:33
326f69a
Compare
Choose a tag to compare

Features:

  • Introduce Y036 (check for badly defined __exit__ and __aexit__ methods).
  • Introduce Y037 (Use PEP 604 syntax instead of typing.Union and typing.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.

22.3.0

26 Mar 19:18
e5a469b
Compare
Choose a tag to compare

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.

22.2.0

21 Feb 01:35
411e1aa
Compare
Choose a tag to compare

Bugfixes:

  • fix bugs in several error codes so that e.g. _T = typing.TypeVar("_T") is
    recognised as a TypeVar 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 TypeVars were erroneously flagged as unused if they were only used in
    a typing.Union subscript.
  • improve unclear error messages for Y022, Y023 and Y027 error codes.

Features:

  • introduce Y032 (prefer object to Any 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 TypeVars instead).
  • introduce Y035 (__all__ in a stub has the same semantics as at runtime).