flake8-pyi


Nameflake8-pyi JSON
Version 20.10.0 PyPI version JSON
download
home_pagehttps://github.com/ambv/flake8-pyi
SummaryA plugin for flake8 to enable linting .pyi files.
upload_time2020-10-18 06:18:04
maintainer
docs_urlNone
authorŁukasz Langa
requires_python>=3.6
licenseMIT
keywords flake8 pyi bugs pyflakes pylint linter qa
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==========
flake8-pyi
==========

A plugin for Flake8 that provides specializations for
`type hinting stub files <https://www.python.org/dev/peps/pep-0484/#stub-files>`_,
especially interesting for linting
`typeshed <https://github.com/python/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 <mailto:lukasz@langa.pl>`_ and
`Jelle Zijlstra <mailto:jelle.zijlstra@gmail.com>`_.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ambv/flake8-pyi",
    "name": "flake8-pyi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "flake8 pyi bugs pyflakes pylint linter qa",
    "author": "\u0141ukasz Langa",
    "author_email": "lukasz@langa.pl",
    "download_url": "https://files.pythonhosted.org/packages/23/23/8e9fb5c16c1c5a37ce15627599addebbaa6061aa90f2f164553933e767c2/flake8-pyi-20.10.0.tar.gz",
    "platform": "",
    "description": "==========\nflake8-pyi\n==========\n\nA plugin for Flake8 that provides specializations for\n`type hinting stub files <https://www.python.org/dev/peps/pep-0484/#stub-files>`_,\nespecially interesting for linting\n`typeshed <https://github.com/python/typeshed/>`_.\n\n\nFunctionality\n-------------\n\n1. Adds the ``.pyi`` extension to the default value of the ``--filename``\n   command-line argument to Flake8.  This means stubs are linted by default with\n   this plugin enabled, without needing to explicitly list every file.\n\n2. Modifies PyFlakes runs for ``.pyi`` files to defer checking type annotation\n   expressions after the entire file has been read.  This enables support for\n   first-class forward references that stub files use.\n\nThe latter should ideally be merged into ``flake8`` as the integration is\ncurrently pretty brittle (might break with future versions of ``pyflakes``,\n``flake8``, or due to interactions with other overly clever plugins).\n\n\nList of warnings\n----------------\n\nThis plugin reserves codes starting with **Y0**. The following warnings are\ncurrently emitted:\n\n* Y001: Names of TypeVars in stubs should start with `_`. This makes sure you\n  don't accidentally expose names internal to the stub.\n* Y002: If test must be a simple comparison against `sys.platform` or\n  `sys.version_info`. Stub files support simple conditionals to indicate\n  differences between Python versions or platforms, but type checkers only\n  understand a limited subset of Python syntax, and this warning triggers on\n  conditionals that type checkers will probably not understand.\n* Y003: Unrecognized `sys.version_info` check. Similar, but triggers on some\n  comparisons involving version checks.\n* Y004: Version comparison must use only major and minor version. Type checkers\n  like mypy don't know about patch versions of Python (e.g. 3.4.3 versus 3.4.4),\n  only major and minor versions (3.3 versus 3.4). Therefore, version checks in\n  stubs should only use the major and minor versions. If new functionality was\n  introduced in a patch version, pretend that it was there all along.\n* Y005: Version comparison must be against a length-n tuple.\n* Y006: Use only < and >= for version comparisons. Comparisons involving > and\n  <= may produce unintuitive results when tools do use the full sys.version_info\n  tuple.\n* Y007: Unrecognized `sys.platform` check. Platform checks should be simple\n  string comparisons.\n* Y008: Unrecognized platform. To prevent you from typos, we warn if you use a\n  platform name outside a small set of known platforms (e.g. \"linux\" and\n  \"win32\").\n* Y009: Empty body should contain \"...\", not \"pass\". This is just a stylistic\n  choice, but it's the one typeshed made.\n* Y010: Function body must contain only \"...\". Stub files should not contain\n  code, so function bodies should be empty. Currently, we make exceptions for\n  raise statements and for assignments in `__init__` methods.\n* Y011: All default values for typed function arguments must be \"...\". Type\n  checkers ignore the default value, so the default value is not useful\n  information in a stub file.\n* Y012: Class body must not contain \"pass\".\n* Y013: Non-empty class body must not contain \"...\".\n* Y014: All default values for arguments must be \"...\". A stronger version\n  of Y011 that includes arguments without type annotations.\n* Y015: Attribute must not have a default value other than \"...\".\n\nThe following warnings are disabled by default:\n\n* Y090: Use explicit attributes instead of assignments in `__init__`. This\n  is a stricter version of Y010. Instead of::\n\n    class Thing:\n        def __init__(self, x: str) -> None:\n            self.x = x\n\n  you should write::\n\n     class Thing:\n         x: str\n         def __init__(self, x: str) -> None: ...\n\n* Y091: Function body must not contain \"raise\".\n* Y092: Top-level attribute must not have a default value.\n\nLicense\n-------\n\nMIT\n\n\nTests\n-----\n\nJust run::\n\n    python3.6 setup.py test\n\nOr if you prefer::\n\n    tox\n\nNote: tests require 3.6+ due to testing variable annotations.\n\n\nChange Log\n----------\n\n20.10.0\n~~~~~~~\n\n* support Python 3.9\n\n20.5.0\n~~~~~~\n\n* support flake8 3.8.0\n* introduce Y091 (function body must not contain \"raise\")\n* introduce Y015 (attribute must not have a default value other than \"...\")\n* introduce Y092 (top-level attribute must not have a default value)\n\n19.3.0\n~~~~~~\n\n* update pyflakes dependency\n\n19.2.0\n~~~~~~~\n\n* support Python 3.7\n* add a check for non-ellipsis, non-typed arguments\n* add checks for checking empty classes\n* use --stdin-display-name as the filename when reading from stdin\n\n18.3.1\n~~~~~~\n\n* introduce Y011\n\n18.3.0\n~~~~~~\n\n* (release herp derp, don't use)\n\n17.3.0\n~~~~~~\n\n* introduce Y001 - Y010\n* introduce optional Y090\n\n17.1.0\n~~~~~~\n\n* handle ``del`` statements in stub files\n\n16.12.2\n~~~~~~~\n\n* handle annotated assignments in 3.6+ with forward reference support\n\n16.12.1\n~~~~~~~\n\n* handle forward references during subclassing on module level\n\n* handle forward references during type aliasing assignments on module level\n\n16.12.0\n~~~~~~~\n\n* first published version\n\n* date-versioned\n\n\nAuthors\n-------\n\nGlued together by `\u0141ukasz Langa <mailto:lukasz@langa.pl>`_ and\n`Jelle Zijlstra <mailto:jelle.zijlstra@gmail.com>`_.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A plugin for flake8 to enable linting .pyi files.",
    "version": "20.10.0",
    "split_keywords": [
        "flake8",
        "pyi",
        "bugs",
        "pyflakes",
        "pylint",
        "linter",
        "qa"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "62971f0eebe55fc1512d2229481b2e7f",
                "sha256": "ff5dfc40bffa878f6ce95bcfd9a6ad14c44b85cbe99c4864e729301bf54267f0"
            },
            "downloads": -1,
            "filename": "flake8_pyi-20.10.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "62971f0eebe55fc1512d2229481b2e7f",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 9647,
            "upload_time": "2020-10-18T06:18:03",
            "upload_time_iso_8601": "2020-10-18T06:18:03.030793Z",
            "url": "https://files.pythonhosted.org/packages/58/06/59b8d6875b3ca097e4946f3453db5ceddbce44400a220ad74a8b83f13981/flake8_pyi-20.10.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "8ffdd99e735eec71516675420c718b74",
                "sha256": "cee3b20a5123152c697870e7e800b60e3c95eb89e272a2b63d8cf55cafb0472c"
            },
            "downloads": -1,
            "filename": "flake8-pyi-20.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8ffdd99e735eec71516675420c718b74",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12814,
            "upload_time": "2020-10-18T06:18:04",
            "upload_time_iso_8601": "2020-10-18T06:18:04.554786Z",
            "url": "https://files.pythonhosted.org/packages/23/23/8e9fb5c16c1c5a37ce15627599addebbaa6061aa90f2f164553933e767c2/flake8-pyi-20.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-10-18 06:18:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "ambv",
    "error": "Could not fetch GitHub repository",
    "lcname": "flake8-pyi"
}
        
Elapsed time: 0.20383s