flake8-typing-collections


Nameflake8-typing-collections JSON
Version 2.0 PyPI version JSON
download
home_pagehttps://github.com/atollk/flake8-typing-collections
SummaryA flake8 plugin that checks the use of type alternatives from the typing module over actual run time types, especially from the collections module.
upload_time2023-07-14 23:32:34
maintainer
docs_urlNone
authorAndreas Tollkötter
requires_python>=3.8
licenseMIT
keywords flake8 typing type-annotations
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # flake8-typing-collections
A flake8 plugin that checks the use of type alternatives from
the `typing` module over actual run time types, especially from
the `collections` module.

## Options

The plugin offers the following flags to select which errors to enable.
All errors that are not explicitly enabled, are not reported.

* `--tyc_generic_alt`: Enables `TYC101`, `TYC102`, `TYC103`, `TYC106`, 
`TYC107`, `TYC108`, `TYC109`, `TYC110`, `TYC111`, `TYC112`, `TYC114`, 
`TYC115`, `TYC116`, `TYC117`, `TYC118`, `TYC119`, `TYC120`, `TYC121`, 
`TYC122`, `TYC123`, `TYC124`, `TYC125`, `TYC126`, `TYC127`, `TYC128`,
`TYC129`, `TYC130`, `TYC131`, and `TYC132`. 
* `--tyc_alias_alt`: Enables `TYC104`, `TYC105`, and `TYC113`.
* `--tyc_general_args`: Enables `TYC200`, `TYC201`, and `TYC202`.

If none of these flags is given, the default selection is used instead,
which is `--tyc_generic_alt` and `--tyc_general_args`.

## Error Codes

## TYC1xx class

The `typing` module defines several generic versions of built-in
classes, such as `typing.List[T]` instead of `list`. Their usage
is preferred.

```python
# Good
def sum_list(x: List[SupportsFloat]) -> float:
    ...

# Bad
def sum_list(x: list) -> float:
    ...
```

### TYC100

Use `typing.Iterable` instead of `collections.abc.Iterable` for type annotations.


### TYC101

Use `typing.Iterator` instead of `collections.abc.Iterator` for type annotations.


### TYC102

Use `typing.Reversible` instead of `collections.abc.Reversible` for type annotations.


### TYC103

Use `typing.Container` instead of `collections.abc.Container` for type annotations.


### TYC104

Use `typing.Hashable` instead of `collections.abc.Hashable` for type annotations.


### TYC105

Use `typing.Sized` instead of `collections.abc.Sized` for type annotations.


### TYC106

Use `typing.Collection` instead of `collections.abc.Collection` for type annotations.


### TYC107

Use `typing.AbstractSet` instead of `collections.abc.Set` for type annotations.


### TYC108

Use `typing.MutableSet` instead of `collections.abc.MutableSet` for type annotations.


### TYC109

Use `typing.Mapping` instead of `collections.abc.Mapping` for type annotations.


### TYC110

Use `typing.MutableMapping` instead of `collections.abc.MutableMapping` for type annotations.


### TYC111

Use `typing.Sequence` instead of `collections.abc.Sequence` for type annotations.


### TYC112

Use `typing.MutableSequence` instead of `collections.abc.MutableSequence` for type annotations.


### TYC113

Use `typing.ByteString` instead of `bytes` for type annotations.


### TYC114

Use `typing.Deque` instead of `collections.Deque` for type annotations.


### TYC115

Use `typing.List` instead of `list` for type annotations.


### TYC116

Use `typing.Set` instead of `set` for type annotations.


### TYC117

Use `typing.FrozenSet` instead of `frozenset` for type annotations.


### TYC118

Use `typing.MappingView` instead of `collections.abc.MappingView` for type annotations.


### TYC119

Use `typing.KeysView` instead of `collections.abc.KeysView` for type annotations.


### TYC120

Use `typing.ItemsView` instead of `collections.abc.ItemsView` for type annotations.


### TYC121

Use `typing.ValuesView` instead of `collections.abc.ValuesView` for type annotations.


### TYC122

Use `typing.Awaitable` instead of `collections.abc.Awaitable` for type annotations.


### TYC123

Use `typing.Coroutine` instead of `collections.abc.Coroutine` for type annotations.


### TYC124

Use `typing.AsyncIterable` instead of `collections.abc.AsyncIterable` for type annotations.


### TYC125

Use `typing.AsyncIterator` instead of `collections.abc.AsyncIterator` for type annotations.


### TYC126

Use `typing.ContextManager` instead of `contextlib.AbstractContextManager` for type annotations.


### TYC127

Use `typing.AsyncContextManager` instead of `contextlib.AbstractAsyncContextManager` for type annotations.


### TYC128

Use `typing.Dict` instead of `dict` for type annotations.


### TYC129

Use `typing.DefaultDict` instead of `collections.defaultdict` for type annotations.


### TYC130

Use `typing.OrderedDict` instead of `collections.OrderedDict` for type annotations.


### TYC131

Use `typing.Counter` instead of `collections.Counter` for type annotations.


### TYC132

Use `typing.ChainMap` instead of `collections.ChainMap` for type annotations.






## TYC2xx class

The documentation of the `typing` module recommends to use
more general types such as `typing.Sequence` over specialized
types such as `typing.List` in function parameters.

```python
# Good
def sum_list(x: Sequence[int]) -> int:
    ...

# Bad
def sum_list(x: List[int]) -> int:
    ...
```

### TYC200

Use `typing.Sequence` or `typing.MutableSequence`
instead of `typing.List` in function arguments.

### TYC201

Use `typing.AbstractSet` or `typing.MutableSet`
instead of `typing.Set` in function arguments.

### TYC201

Use `typing.Mapping` or `typing.MutableMapping`
instead of `typing.Dict` in function arguments.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/atollk/flake8-typing-collections",
    "name": "flake8-typing-collections",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "flake8,typing,type-annotations",
    "author": "Andreas Tollk\u00f6tter",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/20/c2/79a2b45f8321a2ca48fca355c41c07ddacbe78108703b82e0e30f709bb20/flake8-typing-collections-2.0.tar.gz",
    "platform": null,
    "description": "# flake8-typing-collections\nA flake8 plugin that checks the use of type alternatives from\nthe `typing` module over actual run time types, especially from\nthe `collections` module.\n\n## Options\n\nThe plugin offers the following flags to select which errors to enable.\nAll errors that are not explicitly enabled, are not reported.\n\n* `--tyc_generic_alt`: Enables `TYC101`, `TYC102`, `TYC103`, `TYC106`, \n`TYC107`, `TYC108`, `TYC109`, `TYC110`, `TYC111`, `TYC112`, `TYC114`, \n`TYC115`, `TYC116`, `TYC117`, `TYC118`, `TYC119`, `TYC120`, `TYC121`, \n`TYC122`, `TYC123`, `TYC124`, `TYC125`, `TYC126`, `TYC127`, `TYC128`,\n`TYC129`, `TYC130`, `TYC131`, and `TYC132`. \n* `--tyc_alias_alt`: Enables `TYC104`, `TYC105`, and `TYC113`.\n* `--tyc_general_args`: Enables `TYC200`, `TYC201`, and `TYC202`.\n\nIf none of these flags is given, the default selection is used instead,\nwhich is `--tyc_generic_alt` and `--tyc_general_args`.\n\n## Error Codes\n\n## TYC1xx class\n\nThe `typing` module defines several generic versions of built-in\nclasses, such as `typing.List[T]` instead of `list`. Their usage\nis preferred.\n\n```python\n# Good\ndef sum_list(x: List[SupportsFloat]) -> float:\n    ...\n\n# Bad\ndef sum_list(x: list) -> float:\n    ...\n```\n\n### TYC100\n\nUse `typing.Iterable` instead of `collections.abc.Iterable` for type annotations.\n\n\n### TYC101\n\nUse `typing.Iterator` instead of `collections.abc.Iterator` for type annotations.\n\n\n### TYC102\n\nUse `typing.Reversible` instead of `collections.abc.Reversible` for type annotations.\n\n\n### TYC103\n\nUse `typing.Container` instead of `collections.abc.Container` for type annotations.\n\n\n### TYC104\n\nUse `typing.Hashable` instead of `collections.abc.Hashable` for type annotations.\n\n\n### TYC105\n\nUse `typing.Sized` instead of `collections.abc.Sized` for type annotations.\n\n\n### TYC106\n\nUse `typing.Collection` instead of `collections.abc.Collection` for type annotations.\n\n\n### TYC107\n\nUse `typing.AbstractSet` instead of `collections.abc.Set` for type annotations.\n\n\n### TYC108\n\nUse `typing.MutableSet` instead of `collections.abc.MutableSet` for type annotations.\n\n\n### TYC109\n\nUse `typing.Mapping` instead of `collections.abc.Mapping` for type annotations.\n\n\n### TYC110\n\nUse `typing.MutableMapping` instead of `collections.abc.MutableMapping` for type annotations.\n\n\n### TYC111\n\nUse `typing.Sequence` instead of `collections.abc.Sequence` for type annotations.\n\n\n### TYC112\n\nUse `typing.MutableSequence` instead of `collections.abc.MutableSequence` for type annotations.\n\n\n### TYC113\n\nUse `typing.ByteString` instead of `bytes` for type annotations.\n\n\n### TYC114\n\nUse `typing.Deque` instead of `collections.Deque` for type annotations.\n\n\n### TYC115\n\nUse `typing.List` instead of `list` for type annotations.\n\n\n### TYC116\n\nUse `typing.Set` instead of `set` for type annotations.\n\n\n### TYC117\n\nUse `typing.FrozenSet` instead of `frozenset` for type annotations.\n\n\n### TYC118\n\nUse `typing.MappingView` instead of `collections.abc.MappingView` for type annotations.\n\n\n### TYC119\n\nUse `typing.KeysView` instead of `collections.abc.KeysView` for type annotations.\n\n\n### TYC120\n\nUse `typing.ItemsView` instead of `collections.abc.ItemsView` for type annotations.\n\n\n### TYC121\n\nUse `typing.ValuesView` instead of `collections.abc.ValuesView` for type annotations.\n\n\n### TYC122\n\nUse `typing.Awaitable` instead of `collections.abc.Awaitable` for type annotations.\n\n\n### TYC123\n\nUse `typing.Coroutine` instead of `collections.abc.Coroutine` for type annotations.\n\n\n### TYC124\n\nUse `typing.AsyncIterable` instead of `collections.abc.AsyncIterable` for type annotations.\n\n\n### TYC125\n\nUse `typing.AsyncIterator` instead of `collections.abc.AsyncIterator` for type annotations.\n\n\n### TYC126\n\nUse `typing.ContextManager` instead of `contextlib.AbstractContextManager` for type annotations.\n\n\n### TYC127\n\nUse `typing.AsyncContextManager` instead of `contextlib.AbstractAsyncContextManager` for type annotations.\n\n\n### TYC128\n\nUse `typing.Dict` instead of `dict` for type annotations.\n\n\n### TYC129\n\nUse `typing.DefaultDict` instead of `collections.defaultdict` for type annotations.\n\n\n### TYC130\n\nUse `typing.OrderedDict` instead of `collections.OrderedDict` for type annotations.\n\n\n### TYC131\n\nUse `typing.Counter` instead of `collections.Counter` for type annotations.\n\n\n### TYC132\n\nUse `typing.ChainMap` instead of `collections.ChainMap` for type annotations.\n\n\n\n\n\n\n## TYC2xx class\n\nThe documentation of the `typing` module recommends to use\nmore general types such as `typing.Sequence` over specialized\ntypes such as `typing.List` in function parameters.\n\n```python\n# Good\ndef sum_list(x: Sequence[int]) -> int:\n    ...\n\n# Bad\ndef sum_list(x: List[int]) -> int:\n    ...\n```\n\n### TYC200\n\nUse `typing.Sequence` or `typing.MutableSequence`\ninstead of `typing.List` in function arguments.\n\n### TYC201\n\nUse `typing.AbstractSet` or `typing.MutableSet`\ninstead of `typing.Set` in function arguments.\n\n### TYC201\n\nUse `typing.Mapping` or `typing.MutableMapping`\ninstead of `typing.Dict` in function arguments.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A flake8 plugin that checks the use of type alternatives from the typing module over actual run time types, especially from the collections module.",
    "version": "2.0",
    "project_urls": {
        "Homepage": "https://github.com/atollk/flake8-typing-collections"
    },
    "split_keywords": [
        "flake8",
        "typing",
        "type-annotations"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ab0887fa9ccd22c22cbe830138482ca19d9f9c90b3c958084b4b155414b1670d",
                "md5": "f8a1a81d2c646a6cbc7bf656e1cc2e2d",
                "sha256": "f64d95d3ae2f39402e9845c8943647e087063692fb4be47de8a863db79087f58"
            },
            "downloads": -1,
            "filename": "flake8_typing_collections-2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f8a1a81d2c646a6cbc7bf656e1cc2e2d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8887,
            "upload_time": "2023-07-14T23:32:33",
            "upload_time_iso_8601": "2023-07-14T23:32:33.542700Z",
            "url": "https://files.pythonhosted.org/packages/ab/08/87fa9ccd22c22cbe830138482ca19d9f9c90b3c958084b4b155414b1670d/flake8_typing_collections-2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "20c279a2b45f8321a2ca48fca355c41c07ddacbe78108703b82e0e30f709bb20",
                "md5": "492238de7eda6fd3d20b639a666ada15",
                "sha256": "8d96db395020542c62088fcb908f90b1cee827e83da60a682c8c27f85a59aac0"
            },
            "downloads": -1,
            "filename": "flake8-typing-collections-2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "492238de7eda6fd3d20b639a666ada15",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8854,
            "upload_time": "2023-07-14T23:32:34",
            "upload_time_iso_8601": "2023-07-14T23:32:34.684379Z",
            "url": "https://files.pythonhosted.org/packages/20/c2/79a2b45f8321a2ca48fca355c41c07ddacbe78108703b82e0e30f709bb20/flake8-typing-collections-2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-14 23:32:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "atollk",
    "github_project": "flake8-typing-collections",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "flake8-typing-collections"
}
        
Elapsed time: 0.08562s