A plugin for Flake8 that provides specializations for type hinting stub files

Overview

flake8-pyi

A plugin for Flake8 that provides specializations for type hinting stub files, especially interesting for linting typeshed.

Functionality

  1. Adds the .pyi extension to the default value of the --filename command-line argument to Flake8. This means stubs are linted by default with this plugin enabled, without needing to explicitly list every file.
  2. Modifies PyFlakes runs for .pyi files to defer checking type annotation expressions after the entire file has been read. This enables support for first-class forward references that stub files use.

The latter should ideally be merged into flake8 as the integration is currently pretty brittle (might break with future versions of pyflakes, flake8, or due to interactions with other overly clever plugins).

List of warnings

This plugin reserves codes starting with Y0. The following warnings are currently emitted:

  • Y001: Names of TypeVars in stubs should start with _. This makes sure you don't accidentally expose names internal to the stub.
  • Y002: If test must be a simple comparison against sys.platform or sys.version_info. Stub files support simple conditionals to indicate differences between Python versions or platforms, but type checkers only understand a limited subset of Python syntax, and this warning triggers on conditionals that type checkers will probably not understand.
  • Y003: Unrecognized sys.version_info check. Similar, but triggers on some comparisons involving version checks.
  • Y004: Version comparison must use only major and minor version. Type checkers like mypy don't know about patch versions of Python (e.g. 3.4.3 versus 3.4.4), only major and minor versions (3.3 versus 3.4). Therefore, version checks in stubs should only use the major and minor versions. If new functionality was introduced in a patch version, pretend that it was there all along.
  • Y005: Version comparison must be against a length-n tuple.
  • Y006: Use only < and >= for version comparisons. Comparisons involving > and <= may produce unintuitive results when tools do use the full sys.version_info tuple.
  • Y007: Unrecognized sys.platform check. Platform checks should be simple string comparisons.
  • Y008: Unrecognized platform. To prevent you from typos, we warn if you use a platform name outside a small set of known platforms (e.g. "linux" and "win32").
  • Y009: Empty body should contain "...", not "pass". This is just a stylistic choice, but it's the one typeshed made.
  • Y010: Function body must contain only "...". Stub files should not contain code, so function bodies should be empty. Currently, we make exceptions for raise statements and for assignments in __init__ methods.
  • Y011: All default values for typed function arguments must be "...". Type checkers ignore the default value, so the default value is not useful information in a stub file.
  • Y012: Class body must not contain "pass".
  • Y013: Non-empty class body must not contain "...".
  • Y014: All default values for arguments must be "...". A stronger version of Y011 that includes arguments without type annotations.
  • Y015: Attribute must not have a default value other than "...".

The following warnings are disabled by default:

  • Y090: Use explicit attributes instead of assignments in __init__. This is a stricter version of Y010. Instead of:

    class Thing:
        def __init__(self, x: str) -> None:
            self.x = x
    

    you should write:

    class Thing:
        x: str
        def __init__(self, x: str) -> None: ...
    
  • Y091: Function body must not contain "raise".

  • Y092: Top-level attribute must not have a default value.

License

MIT

Tests

Just run:

python3.6 setup.py test

Or if you prefer:

tox

Note: tests require 3.6+ due to testing variable annotations.

Change Log

20.10.0

  • support Python 3.9

20.5.0

  • 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)

19.3.0

  • update pyflakes dependency

19.2.0

  • 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

18.3.1

  • introduce Y011

18.3.0

  • (release herp derp, don't use)

17.3.0

  • introduce Y001 - Y010
  • introduce optional Y090

17.1.0

  • handle del statements in stub files

16.12.2

  • handle annotated assignments in 3.6+ with forward reference support

16.12.1

  • handle forward references during subclassing on module level
  • handle forward references during type aliasing assignments on module level

16.12.0

  • first published version
  • date-versioned

Authors

Glued together by Łukasz Langa and Jelle Zijlstra.

Comments
  • Warn-only with comments typeshed_primer

    Warn-only with comments typeshed_primer

    The goal of this PR is to allow typeshed to not ignore NQA102. It does so by making the typeshed_primer job non-blocking (meaning it won't fail even if Flake8 errors are raised), and instead add a comment to the PR to show if the PR would produce any Flake8 error in typeshed. This way, typeshed doesn't need to pre-emptively ignore new errors for flake8-pyi CI to pass.

    This is heavily based on https://github.com/python/typeshed/blob/main/.github/workflows/mypy_primer_comment.yml , but simplified a bit and I extracted the JS scripts for better readability. (CC: @AlexWaygood )

    Note: .github/workflows/check.yml contains extra auto-formatting changes. I don't think they make the PR harder to review (especially if you hide whitespace changes), but I can always revert and/or split it off.

    opened by Avasam 21
  • Add a check for methods that hardcode their return type, but shouldn't

    Add a check for methods that hardcode their return type, but shouldn't

    An attempt at implementing #168 (closes #168).

    Marking this as a draft for now, as I don't think the error message is very good, and I'm not sure how to improve it. I would also be curious to hear what others think of the overall idea before I put any more work in, as well.

    type-feature 
    opened by AlexWaygood 14
  • Keeping this package alive

    Keeping this package alive

    This package can be very helpful for keeping stub files healthy, but development has kind of stalled. For example, typeshed now has some lint-type checks in a custom file (check_new_syntax.py). I'd like to keep such checks in this package in the future, so they can be reused by other repos than typeshed and so we can take advantage of the flake8 ecosystem (e.g., standardized noqa comments).

    Here's a few process improvements I'm thinking of:

    • [x] More maintainers. I think @srittau is already a maintainer, but @Akuli @hauntsaninja @AlexWaygood would you be interested in joining as maintainers?
    • [ ] Making releases easier. Perhaps we should set up a CI pipeline that automatically releases every merged PR to PyPI, so we can quickly upgrade over at typeshed.
    • [x] Moving this repo over to a more general org. @ambv, maybe it can go into github.com/psf?
    opened by JelleZijlstra 14
  • Check for redundant object unions

    Check for redundant object unions

    I'd like a check similar to Y041, but for unions with object. Especially for object | None, coming from a Typescript background, it is not obvious to me that this type union is redundant, and I often make that mistake (or forget about it and leave it in a stub).

    opened by Avasam 11
  • Add Y036 code to check for possible usage of PEP 604 new syntax

    Add Y036 code to check for possible usage of PEP 604 new syntax

    Closes #45.

    @AlexWaygood this is roughly what I had in mind when suggesting a new code, just a simple Use PEP 604 union types instead of {Optional,Union} message. @srittau unfortunately, the check for just importing Optional/Union seems to be not enough, since then any typing.Optional/typing.Union usages are skipped. But luckily the _check_import_or_attribute method already covers that :crossed_fingers:

    type-feature deferred 
    opened by hoefling 11
  • Introduce Y022/Y023/Y024/Y025: Imports linting error codes

    Introduce Y022/Y023/Y024/Y025: Imports linting error codes

    Helps work towards #80 and #32. I've tried to keep these error codes completely cross-compatible between Python 2 and Python 3 -- I think it would be best to leave Python-3-only changes (e.g. disallowing typing.ContextManager and typing_extensions.OrderedDict) can be left for another error code.

    opened by AlexWaygood 10
  • 20.10.0: test suite is failing

    20.10.0: test suite is failing

    I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

    • python3 -sBm build -w
    • install .whl file in </install/prefix>
    • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

    Here is pytest output:

    + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-flake8-pyi-20.10.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-flake8-pyi-20.10.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
    + /usr/bin/pytest -ra
    =========================================================================== test session starts ============================================================================
    platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-0.13.1
    benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
    Using --randomly-seed=3873507879
    rootdir: /home/tkloczko/rpmbuild/BUILD/flake8-pyi-20.10.0
    plugins: mock-3.6.1, cov-2.12.1, anyio-3.3.4, flaky-3.7.0, console-scripts-1.2.0, asyncio-0.16.0, freezegun-0.4.2, flake8-1.0.7, rerunfailures-9.1.1, yagot-0.5.0, forked-1.4.0, ordering-0.6, xdist-2.5.0, Faker-10.0.0, benchmark-3.4.1, pyfakefs-4.5.3, datadir-1.3.1, regressions-2.2.0, timeout-2.0.2, randomly-3.10.3, perf-0.10.1, trio-0.7.0, requests-mock-1.9.3, hypothesis-6.31.5, easy-server-0.8.0
    collected 15 items
    
    tests/test_pyi.py .....F.......F.                                                                                                                                    [100%]
    
    ================================================================================= FAILURES =================================================================================
    ______________________________________________________________________ PyiTestCase.test_function_def _______________________________________________________________________
    
    self = <tests.test_pyi.PyiTestCase testMethod=test_function_def>
    
        def test_function_def(self) -> None:
            stdout_lines = (
                '5:5: Y009 Empty body should contain "...", not "pass"',
                '19:5: Y010 Function body must contain only "..."',
                '23:5: Y010 Function body must contain only "..."',
            )
    >       self.checkFileOutput("emptyfunctions.pyi", stdout_lines=stdout_lines)
    
    tests/test_pyi.py:182:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    tests/test_pyi.py:83: in checkFileOutput
        check_output(
    tests/test_pyi.py:78: in check_output
        self.assertMultiLineEqual(expected, actual)
    E   AssertionError: 'empt[85 chars]pyi:19:5: Y010 Function body must contain only[71 chars]..."' != 'empt[85 chars]pyi:10:1: B903 Data class should either be imm[585 chars]..."'
    E     emptyfunctions.pyi:5:5: Y009 Empty body should contain "...", not "pass"
    E   + emptyfunctions.pyi:10:1: B903 Data class should either be immutable or use __slots__ to save memory. Use collections.namedtuple to generate an immutable class, or enumerate the attributes in a __slot__ declaration in the class to leave attributes mutable.
    E   + emptyfunctions.pyi:14:1: B903 Data class should either be immutable or use __slots__ to save memory. Use collections.namedtuple to generate an immutable class, or enumerate the attributes in a __slot__ declaration in the class to leave attributes mutable.
    E     emptyfunctions.pyi:19:5: Y010 Function body must contain only "..."
    E     emptyfunctions.pyi:23:5: Y010 Function body must contain only "..."
    _______________________________________________________________________ PyiTestCase.test_empty_init ________________________________________________________________________
    
    self = <tests.test_pyi.PyiTestCase testMethod=test_empty_init>
    
        def test_empty_init(self) -> None:
            # should have no output if it's not explicitly selected
    >       self.checkFileOutput("emptyinit.pyi", stdout_lines=())
    
    tests/test_pyi.py:186:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    tests/test_pyi.py:83: in checkFileOutput
        check_output(
    tests/test_pyi.py:78: in check_output
        self.assertMultiLineEqual(expected, actual)
    E   AssertionError: '' != 'emptyinit.pyi:1:1: B903 Data class should[204 chars]ble.'
    E   + emptyinit.pyi:1:1: B903 Data class should either be immutable or use __slots__ to save memory. Use collections.namedtuple to generate an immutable class, or enumerate the attributes in a __slot__ declaration in the class to leave attributes mutable.
    ========================================================================= short test summary info ==========================================================================
    FAILED tests/test_pyi.py::PyiTestCase::test_function_def - AssertionError: 'empt[85 chars]pyi:19:5: Y010 Function body must contain only[71 chars]..."' != 'empt[85 chars...
    FAILED tests/test_pyi.py::PyiTestCase::test_empty_init - AssertionError: '' != 'emptyinit.pyi:1:1: B903 Data class should[204 chars]ble.'
    ====================================================================== 2 failed, 13 passed in 14.35s =======================================================================
    error: Bad exit status from /var/tmp/rpm-tmp.mkEK9d (%check)
    
    opened by kloczek 10
  • Port typeshed's tests/check_new_syntax.py here

    Port typeshed's tests/check_new_syntax.py here

    Typeshed currently has a script that checks a bunch of things that belong here IMO: https://github.com/python/typeshed/blob/af8e37d2736d3a6fbed8f5dfad71580dd417c612/tests/check_new_syntax.py

    • [x] Collections classes in typing: typing.Counter --> collections.Counter etc (related: #46)
    • [x] Built-in generics: List --> list etc
    • [x] typing.(Async)ContextManager --> contextlib.Abstract(Async)ContextManager
    • [x] Preferring typing over typing_extensions when available: typing_extensions.ClassVar --> typing.ClassVar etc
    • [x] Union[str, int] --> str | int (#45)
    • [x] Banning from collections.abc import Set, because it's confusingly different from the built-in set
    • [ ] Ordering sys.version_info checks so that the most recent version is first
    • [x] Ban explicitly inheriting from object in Python 3-only stubs.
    • [x] Disallow using typing.Text in Python 3-only stubs.

    ~~We should probably create one error code per Python version, so that it's easy to e.g. enable errors for not using features new in Python 3.8+. Another option would be to make the errors depend on sys.version_info (maybe too clever, would need good documentation).~~

    type-feature 
    opened by Akuli 9
  • flake8-pyi <22.8.1 is broken using flake8 >=5.0.0

    flake8-pyi <22.8.1 is broken using flake8 >=5.0.0

    flake8 5.0.0 was just released, and flake8-pyi crashes if run with the new version of flake8.

    In the short term, we should maybe pin the required version of flake8 in our setup.py to <5.0.0 and do a hotfix release.

    In order to become compatible with flake8 5.0.0, we'll probably need to either address #183 or just change the monkey-patching of flake8 that we do.

    Thoughts?

    priority-high 
    opened by AlexWaygood 8
  • Enable TypeAlias check by default

    Enable TypeAlias check by default

    And delete the machinery for disabling errors.

    This made this check run on all tests, which helped me find a bug (it triggered on all). I can split the test changes into a separate PR if preferred.

    I'll submit a separate PR to typeshed to disable this check for now.

    Fixes #75. Fixes #86.

    opened by JelleZijlstra 8
  • remove Y092

    remove Y092

    Disabled-by-default error codes are problematic; see #75.

    Y092 finds a fairly harmless error and has significant false positives (python/typeshed#6930). I'm removing it so we can get rid of disabled-by-default errors and simplify our setup.

    opened by JelleZijlstra 8
  • False-positive error for `Final` if it's aliased

    False-positive error for `Final` if it's aliased

    flake8-pyi currently emits a false-positive error for this code, which should be fine:

    from typing_extensions import Final as _Final
    
    CONSTANT: _Final = 5
    

    This might be tricky to fix, since we don't currently track whether imports are aliased at all. Came up in https://github.com/python/typeshed/pull/9470

    type-bug 
    opened by AlexWaygood 0
  • Release 23.1.0 planning

    Release 23.1.0 planning

    Since we use CalVer, we have one "major version bump" a year: the first release after the new year. It might be better to plan breaking/backwards-incompatible changes for the major version bump. Does anybody have anything they'd like to be included in the next release?

    Things I'd like to do:

    • #269.
    • I'd also add typing.Match and typing.Pattern to the imports forbidden by Y022 (Python 3.6 is now long EOL, and unsupported by at least typeshed and mypy).
    opened by AlexWaygood 3
  • Encourage typing_extensions.Unpack for many overload-invariant keywords

    Encourage typing_extensions.Unpack for many overload-invariant keywords

    If a function has many keyword arguments that do not change across all overloads (for example pandas.read_csv). It is more readable and shorter to move all the overload-invariant keywords into a TypedDict and suggest using the Unpack feature which is supported by at least pyright and mypy.

    This would probably need some heuristic of when is it worth recommending Unpack: Using a TypedDict for less than insert magic number keywords is probably not helpful.

    deferred 
    opened by twoertwein 2
  • Compatibility with Python 3.7

    Compatibility with Python 3.7

    Is there any option to say that we need compatibility with Python 3.7? Or are we expected to add any incompatible error codes to the ignore list?

    e.g. Y022 is not possible to fix until Python 3.9 is the minimum supported version (in our library).

    opened by Dreamsorcerer 15
  • Spurious F821 error emitted by pyflakes due to forward references

    Spurious F821 error emitted by pyflakes due to forward references

    Repro:

    from typing import List
    class Outer:
        class Inner1: ...
        class Inner2(List[Outer.Inner1]): ...
    

    Both mypy and pyright are happy with this flake8 complains that it can't identify the name Outer

    Within a .py file, this construct would not be ok, but it appears to be ok within a .pyi file.

    This may be because mypy/pyright do a 2-pass check. I am not sure how flake8/flake8-pyi works here.

    opened by nipunn1313 1
Releases(22.11.0)
  • 22.11.0(Nov 24, 2022)

    Bugfixes:

    • Specify encoding when opening files. Prevents UnicodeDecodeError on Windows when the file contains non-CP1252 characters. Contributed by Avasam.
    • Significant changes have been made to the Y041 check. Previously, Y041 flagged "redundant numeric unions" (e.g. float | int, complex | float or complex | int) in all contexts outside of type aliases. This was incorrect. PEP 484 only specifies that type checkers should treat int as an implicit subtype of float in the specific context of parameter annotations for functions and methods. Y041 has therefore been revised to only emit errors on "redundant numeric unions" in the context of parameter annotations.

    Other changes:

    • Support running with flake8 v6.
    Source code(tar.gz)
    Source code(zip)
  • 22.10.0(Oct 6, 2022)

    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 inside class 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, the FutureWarning is no longer emitted.
    Source code(tar.gz)
    Source code(zip)
  • 22.8.2(Aug 31, 2022)

    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.
    Source code(tar.gz)
    Source code(zip)
  • 22.8.1(Aug 2, 2022)

  • 22.8.0(Aug 2, 2022)

    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).
    Source code(tar.gz)
    Source code(zip)
  • 22.7.0(Jul 24, 2022)

    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.
    Source code(tar.gz)
    Source code(zip)
  • 22.5.1(May 19, 2022)

  • 22.5.0(May 10, 2022)

    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.
    Source code(tar.gz)
    Source code(zip)
  • 22.4.1(Apr 18, 2022)

    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.
    Source code(tar.gz)
    Source code(zip)
  • 22.4.0(Apr 16, 2022)

    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.
    Source code(tar.gz)
    Source code(zip)
  • 22.3.0(Mar 26, 2022)

    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.
    Source code(tar.gz)
    Source code(zip)
  • 22.2.0(Feb 21, 2022)

    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).
    Source code(tar.gz)
    Source code(zip)
  • 22.1.0(Jan 23, 2022)

    • extend Y001 to cover ParamSpec and TypeVarTuple in addition to TypeVar
    • 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 (disallow raise 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 TypeVars)
    • introduce Y019 (detect TypeVars 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 over typing_extensions)
    • introduce Y024 (prefer typing.NamedTuple to collections.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 NamedTuples)
    • introduce Y029 (never define __repr__ or __str__)
    • introduce Y030 (use Literal['foo', 'bar'] instead of Literal['foo'] | Literal['bar'])
    • introduce Y031 (use class-based syntax for TypedDicts 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 dependency
    • ast_decompiler has been added as a dependency on Python 3.8 and 3.7
    • support Python 3.10
    • discontinue support for Python 3.6
    Source code(tar.gz)
    Source code(zip)
  • 22.1.0rc1(Jan 23, 2022)

    Pre-release. If all goes well 22.1.0 will follow soon with the exact same code.

    • extend Y001 to cover ParamSpec and TypeVarTuple in addition to TypeVar
    • 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 (disallow raise 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 TypeVars)
    • introduce Y019 (detect TypeVars 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 over typing_extensions)
    • introduce Y024 (prefer typing.NamedTuple to collections.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 NamedTuples)
    • introduce Y029 (never define __repr__ or __str__)
    • introduce Y030 (use Literal['foo', 'bar'] instead of Literal['foo'] | Literal['bar'])
    • introduce Y031 (use class-based syntax for TypedDicts 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 dependency
    • ast_decompiler has been added as a dependency on Python 3.8 and 3.7
    • support Python 3.10
    • discontinue support for Python 3.6
    Source code(tar.gz)
    Source code(zip)
Owner
Łukasz Langa
Python 3.8 & 3.9 Release Manager. llanga on Twitter. Python core developer, hobbyist musician, dad.
Łukasz Langa
Backport Python 3.8+ typing utils & add issubtype & more

typing-utils Backport Python3.8+ typing utils & issubtype & more Install API issubtype get_origin get_args get_type_hints Install pip install typi

10 Nov 09, 2022
Easy saving and switching between multiple KDE configurations.

Konfsave Konfsave is a config manager. That is, it allows you to save, back up, and easily switch between different (per-user) system configurations.

42 Sep 25, 2022
open source tools to generate mypy stubs from protobufs

mypy-protobuf: Generate mypy stub files from protobuf specs We just released a new major release mypy-protobuf 2. on 02/02/2021! It includes some back

Dropbox 527 Jan 03, 2023
Flake8 plugin for managing type-checking imports & forward references

flake8-type-checking Lets you know which imports to put in type-checking blocks. For the imports you've already defined inside type-checking blocks, i

snok 67 Dec 16, 2022
mypy plugin to type check Kubernetes resources

kubernetes-typed mypy plugin to dynamically define types for Kubernetes objects. Features Type checking for Custom Resources Type checking forkubernet

Artem Yarmoliuk 16 Oct 10, 2022
❄️ A flake8 plugin to help you write better list/set/dict comprehensions.

flake8-comprehensions A flake8 plugin that helps you write better list/set/dict comprehensions. Requirements Python 3.6 to 3.9 supported. Installation

Adam Johnson 398 Dec 23, 2022
A plugin for Flake8 that provides specializations for type hinting stub files

flake8-pyi A plugin for Flake8 that provides specializations for type hinting stub files, especially interesting for linting typeshed. Functionality A

Łukasz Langa 58 Jan 04, 2023
Design by contract for Python. Write bug-free code. Add a few decorators, get static analysis and tests for free.

A Python library for design by contract (DbC) and checking values, exceptions, and side-effects. In a nutshell, deal empowers you to write bug-free co

Life4 473 Dec 28, 2022
Code audit tool for python.

Pylama Code audit tool for Python and JavaScript. Pylama wraps these tools: pycodestyle (formerly pep8) © 2012-2013, Florent Xicluna; pydocstyle (form

Kirill Klenov 967 Jan 07, 2023
Naming Convention checker for Python

PEP 8 Naming Conventions Check your code against PEP 8 naming conventions. This module provides a plugin for flake8, the Python code checker. (It repl

Python Code Quality Authority 411 Dec 23, 2022
Mylint - My really simple rendition of how a linter works.

mylint My really simple rendition of how a linter works. This original version was written for my AST article. Since then I've added tests and turned

Tushar Sadhwani 2 Dec 29, 2021
docstring style checker

pydocstyle - docstring style checker pydocstyle is a static analysis tool for checking compliance with Python docstring conventions. pydocstyle suppor

Python Code Quality Authority 982 Jan 03, 2023
Tool for pinpointing circular imports in Python. Find cyclic imports in any project

Pycycle: Find and fix circular imports in python projects Pycycle is an experimental project that aims to help python developers fix their circular de

Vadim Kravcenko 311 Dec 15, 2022
A framework for detecting, highlighting and correcting grammatical errors on natural language text.

Gramformer Human and machine generated text often suffer from grammatical and/or typographical errors. It can be spelling, punctuation, grammatical or

Prithivida 1.3k Jan 08, 2023
Performant type-checking for python.

Pyre is a performant type checker for Python compliant with PEP 484. Pyre can analyze codebases with millions of lines of code incrementally – providi

Facebook 6.2k Jan 04, 2023
Python classes with types validation at runtime.

typedclasses Python classes with types validation at runtime. (Experimental & Under Development) Installation You can install this library using Pytho

Izhar Ahmad 8 Feb 06, 2022
Flake8 extension to provide force-check option

flake8-force Flake8 extension to provide force-check option. When this option is enabled, flake8 performs all checks even if the target file cannot be

Kenichi Maehashi 9 Oct 29, 2022
Mypy stubs, i.e., type information, for numpy, pandas and matplotlib

Mypy type stubs for NumPy, pandas, and Matplotlib This is a PEP-561-compliant stub-only package which provides type information for matplotlib, numpy

Predictive Analytics Lab 194 Dec 19, 2022
Utilities for refactoring imports in python-like syntax.

aspy.refactor_imports Utilities for refactoring imports in python-like syntax. Installation pip install aspy.refactor_imports Examples aspy.refactor_i

Anthony Sottile 20 Nov 01, 2022
Flake8 Type Annotation Checking

flake8-annotations flake8-annotations is a plugin for Flake8 that detects the absence of PEP 3107-style function annotations and PEP 484-style type co

S. Co1 118 Jan 05, 2023