{"id":22114019,"url":"https://github.com/plinss/flake8-modern-annotations","last_synced_at":"2025-07-25T08:31:14.489Z","repository":{"id":56870597,"uuid":"523888549","full_name":"plinss/flake8-modern-annotations","owner":"plinss","description":"flake8 plugin to validate type annotations accoring to modern practices - Mirror of https://gitlab.linss.com/open-source/flake8/flake8-modern-annotations","archived":false,"fork":false,"pushed_at":"2024-01-06T03:35:50.000Z","size":36,"stargazers_count":4,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-11T18:46:35.733Z","etag":null,"topics":["flake8","flake8-extension","flake8-plugin"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plinss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-11T22:41:46.000Z","updated_at":"2024-06-29T11:39:28.000Z","dependencies_parsed_at":"2022-08-20T12:10:49.524Z","dependency_job_id":null,"html_url":"https://github.com/plinss/flake8-modern-annotations","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plinss%2Fflake8-modern-annotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plinss%2Fflake8-modern-annotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plinss%2Fflake8-modern-annotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plinss%2Fflake8-modern-annotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plinss","download_url":"https://codeload.github.com/plinss/flake8-modern-annotations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227544348,"owners_count":17785198,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flake8","flake8-extension","flake8-plugin"],"created_at":"2024-12-01T11:08:21.421Z","updated_at":"2024-12-01T11:08:22.205Z","avatar_url":"https://github.com/plinss.png","language":"Python","readme":"# [flake8-modern-annotations](https://github.com/plinss/flake8-modern-annotations)\n\nflake8 plugin to validate type annotations accoring to modern practices.\n\n* Postponed Evaluations of Annotations per PEP 563.\n* Standard collection generics per PEP 585.\n* Union types as X | Y per PEP 604.\n* Optional types when PEP 604 Unions are available.\n\n### Activation\n\nBy default the plugin activates according to the Python version used for flake8 \nor when it sees a future import that enables modern annoations, e.g.:\n\n    from __future__ import annotations\n\nOptions exist for each feature to override the automatic activation.\n\n## Installation\n\nStandard python package installation:\n\n    pip install flake8-modern-annotations\n\n\n## Type Aliases\n\nNote that there are some restrictions when using modern annotation proactices with type aliases:\n\n* Forward references\n  * Must use string literals\n  * Unions containing forward references must use `typing.Union`\n\n* Standard collection generics\n  * Cannot be used in type aliases if subscripted on Python \u003c 3.9, e.g. `X: TypeAlias = dict[str, str]`\n\n* Unions\n  * `|` unions cannot be used in type aliases on Python \u003c 3.9\n\nThis plugin will not report errors for the above cases with the default settings.\n\nIt is recommended to use the `TypeAlias` type for type aliases to help this plugin detect them properly in all cases.\n`TypeAlias` is available from `typing` in Python 3.10+ and `typing_extensions` in prior versions.\n\n## Options\n\n`modern-annotations-postponed`\n: Controls validation of postponed annotations (PEP 563), \nchoices: `auto`, `always`, `never` (default: `auto`)\n\n`modern-annotations-deprecated`\n: Controls validation of deprecated types (PEP 585), \nchoices: `auto`, `always`, `never` (default: `auto`)\n\n`modern-annotations-type-alias`\n: Use deprecated types in type aliases (required for older Python \u003c 3.9), \nchoices: `auto`, `always`, `never` (default: `auto`)\n\n`modern-annotations-union`\n: Controls checks for use of typing.Union (PEP 604), \nchoices: `auto`, `always`, `never` (default: `auto`)\n\n`modern-annotations-optional`\n: Controls checks for use of typing.Optional, \nchoices: `auto`, `always`, `never` (default: `auto`)\n\n`modern-annotations-include-name`\n: Include plugin name in messages\n\n`modern-annotations-no-include-name`\n: Do not include plugin name in messages (default setting)\n\nAll options may be specified on the command line with a `--` prefix,\nor can be placed in your flake8 config file.\n\n`auto` settings turn on or off depending on the version of Python that flake8 is running on,\nand the presence of `from __future__ import annotations` in the code, \nwhich enables the modern annotations in Python 3.7+.\n\nIf developing code in Python 3.9+ that is expected to run on 3.7 or 3.8,\nuse `modern-annotations-type-alias=always` to force older behavior of type aliases\nand ensure that the code will work.\n\n\n## Error Codes\n\n| Code   | Message |\n|--------|---------|\n| MDA001 | Remove quotes from variable type annotation 'type'\n| MDA002 | Remove quotes from argument type annotation 'type'\n| MDA003 | Remove quotes from return type annotation 'type'\n| MDA100 | 'typing.Tuple' is deprecated, remove from import\n| MDA101 | 'typing.List' is deprecated, remove from import\n| MDA102 | 'typing.Dict' is deprecated, remove from import\n| MDA103 | 'typing.Set' is deprecated, remove from import\n| MDA104 | 'typing.FrozenSet' is deprecated, remove from import\n| MDA105 | 'typing.Type' is deprecated, remove from import\n| MDA110 | 'typing.Deque' is deprecated, replace with 'collections.deque'\n| MDA111 | 'typing.DefaultDict' is deprecated, replace with 'collections.defaultdict'\n| MDA112 | 'typing.OrderedDict' is deprecated, replace with 'collections.OrderedDict'\n| MDA113 | 'typing.Counter' is deprecated, replace with 'collections.Counter'\n| MDA114 | 'typing.ChainMap' is deprecated, replace with 'collections.ChainMap'\n| MDA120 | 'typing.Awaitable' is deprecated, replace with 'collections.abc.Awaitable'\n| MDA121 | 'typing.Coroutine' is deprecated, replace with 'collections.abc.Coroutine'\n| MDA122 | 'typing.AsyncIterable' is deprecated, replace with 'collections.abc.AsyncIterable'\n| MDA123 | 'typing.AsyncIterator' is deprecated, replace with 'collections.abc.AsyncIterator'\n| MDA124 | 'typing.AsyncGenerator' is deprecated, replace with 'collections.abc.AsyncGenerator'\n| MDA125 | 'typing.Iterable' is deprecated, replace with 'collections.abc.Iterable'\n| MDA126 | 'typing.Iterator' is deprecated, replace with 'collections.abc.Iterator'\n| MDA127 | 'typing.Generator' is deprecated, replace with 'collections.abc.Generator'\n| MDA128 | 'typing.Reversible' is deprecated, replace with 'collections.abc.Reversible'\n| MDA129 | 'typing.Container' is deprecated, replace with 'collections.abc.Container'\n| MDA130 | 'typing.Collection' is deprecated, replace with 'collections.abc.Collection'\n| MDA131 | 'typing.Callable' is deprecated, replace with 'collections.abc.Callable'\n| MDA132 | 'typing.AbstractSet' is deprecated, replace with 'collections.abc.Set'\n| MDA133 | 'typing.MutableSet' is deprecated, replace with 'collections.abc.MutableSet'\n| MDA134 | 'typing.Mapping' is deprecated, replace with 'collections.abc.Mapping'\n| MDA135 | 'typing.MutableMapping' is deprecated, replace with 'collections.abc.MutableMapping'\n| MDA136 | 'typing.Sequence' is deprecated, replace with 'collections.abc.Sequence'\n| MDA137 | 'typing.MutableSequence' is deprecated, replace with 'collections.abc.MutableSequence'\n| MDA138 | 'typing.ByteString' is deprecated, replace with 'collections.abc.ByteString'\n| MDA139 | 'typing.MappingView' is deprecated, replace with 'collections.abc.MappingView'\n| MDA140 | 'typing.KeysView' is deprecated, replace with 'collections.abc.KeysView'\n| MDA141 | 'typing.ItemsView' is deprecated, replace with 'collections.abc.ItemsView'\n| MDA142 | 'typing.ValuesView' is deprecated, replace with 'collections.abc.ValuesView'\n| MDA150 | 'typing.ContextManager' is deprecated, replace with 'contextlib.AbstractContextManager'\n| MDA151 | 'typing.AsyncContextManager' is deprecated, replace with 'contextlib.AbstractAsyncContextManager'\n| MDA160 | 'typing.Pattern' is deprecated, replace with 're.Pattern'\n| MDA161 | 'typing.Match' is deprecated, replace with 're.Match'\n| MDA200 | Replace 'Tuple' with 'tuple'\n| MDA201 | Replace 'List' with 'list'\n| MDA202 | Replace 'Dict' with 'dict'\n| MDA203 | Replace 'Set' with 'set'\n| MDA204 | Replace 'FrozenSet' with 'frozenset'\n| MDA205 | Replace 'Type' with 'type'\n| MDA210 | Replace 'Deque' with 'collections.deque'\n| MDA211 | Replace 'DefaultDict' with 'collections.defaultdict'\n| MDA212 | Replace 'OrderedDict' with 'collections.OrderedDict'\n| MDA213 | Replace 'Counter' with 'collections.Counter'\n| MDA214 | Replace 'ChainMap' with 'collections.ChainMap'\n| MDA220 | Replace 'Awaitable' with 'collections.abc.Awaitable'\n| MDA221 | Replace 'Coroutine' with 'collections.abc.Coroutine'\n| MDA222 | Replace 'AsyncIterable' with 'collections.abc.AsyncIterable'\n| MDA223 | Replace 'AsyncIterator' with 'collections.abc.AsyncIterator'\n| MDA224 | Replace 'AsyncGenerator' with 'collections.abc.AsyncGenerator'\n| MDA225 | Replace 'Iterable' with 'collections.abc.Iterable'\n| MDA226 | Replace 'Iterator' with 'collections.abc.Iterator'\n| MDA227 | Replace 'Generator' with 'collections.abc.Generator'\n| MDA228 | Replace 'Reversible' with 'collections.abc.Reversible'\n| MDA229 | Replace 'Container' with 'collections.abc.Container'\n| MDA230 | Replace 'Collection' with 'collections.abc.Collection'\n| MDA231 | Replace 'Callable' with 'collections.abc.Callable'\n| MDA232 | Replace 'AbstractSet' with 'collections.abc.Set'\n| MDA233 | Replace 'MutableSet' with 'collections.abc.MutableSet'\n| MDA234 | Replace 'Mapping' with 'collections.abc.Mapping'\n| MDA235 | Replace 'MutableMapping' with 'collections.abc.MutableMapping'\n| MDA236 | Replace 'Sequence' with 'collections.abc.Sequence'\n| MDA237 | Replace 'MutableSequence' with 'collections.abc.MutableSequence'\n| MDA238 | Replace 'ByteString' with 'collections.abc.ByteString'\n| MDA239 | Replace 'MappingView' with 'collections.abc.MappingView'\n| MDA240 | Replace 'KeysView' with 'collections.abc.KeysView'\n| MDA241 | Replace 'ItemsView' with 'collections.abc.ItemsView'\n| MDA242 | Replace 'ValuesView' with 'collections.abc.ValuesView'\n| MDA250 | Replace 'ContextManager' with 'contextlib.AbstractContextManager'\n| MDA251 | Replace 'AsyncContextManager' with 'contextlib.AbstractAsyncContextManager'\n| MDA260 | Replace 'Pattern' with 're.Pattern'\n| MDA261 | Replace 'Match' with 're.Match'\n| MDA400 | 'typing.Union' is deprecated, remove from import\n| MDA401 | Replace 'Union' with '\u0026#x7c;'\n| MDA500 | 'typing.Optional' is deprecated, remove from import\n| MDA501 | Replace 'Optional' with '\u0026#x7c; None'\n\n\n## Examples\n\n```\nx: 'Foo'  \u003c-- MDA001\ndef foo(x: 'Foo') -\u003e None:  \u003c-- MDA002\ndef foo(x: Foo) -\u003e 'Bar':  \u003c-- MDA003\n\nfrom typing import Dict  \u003c-- MDA102\nx: Dict[str, str]  \u003c-- MDA202\n\nfrom typing import Dict\nMyDict = Dict[str, int]  \u003c-- no error on Python 3.7/3.8\n\nfrom typing import Union  \u003c-- MDA400\nx: Union[int, float]  \u003c-- MDA401\n\nfrom typing import Optional  \u003c-- MDA500\nx: Optional[int]  \u003c-- MDA501\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplinss%2Fflake8-modern-annotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplinss%2Fflake8-modern-annotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplinss%2Fflake8-modern-annotations/lists"}