Skip to content

Commit

Permalink
Disallow deprecated aliases from typing (PlasmaPy#2445)
Browse files Browse the repository at this point in the history
* Disallow deprecated typing aliases

* typing.Callable → collections.abc.Callable

* Remove comments
  • Loading branch information
namurphy authored Jan 6, 2024
1 parent 75bf724 commit 627305a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,22 @@ pandas = "pd"
[tool.ruff.flake8-unused-arguments]
ignore-variadic-names = true

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"typing.Callable".msg = "Deprecated alias. Change to collections.abc.Callable"
"typing.Collection".msg = "Deprecated alias. Change to collections.abc.Collection"
"typing.DefaultDict".msg = "Deprecated alias. Change to collections.defaultdict"
"typing.Dict".msg = "Deprecated alias. Change to dict"
"typing.Generator".msg = "Deprecated alias. Change to collections.abc.Generator"
"typing.Iterable".msg = "Deprecated alias. Change to collections.abc.Iterable"
"typing.Iterator".msg = "Deprecated alias. Change to collections.abc.Iterator"
"typing.List".msg = "Deprecated alias. Change to list"
"typing.Mapping".msg = "Deprecated alias. Change to collections.abc.mapping"
"typing.MutableMapping".msg = "Deprecated alias. Change to collections.abc.MutableMapping"
"typing.Sequence".msg = "Deprecated alias. Change to collections.abc.Sequence"
"typing.Set".msg = "Deprecated alias. Change to set"
"typing.Tuple".msg = "Deprecated alias. Change to tuple"
"typing.Type".msg = "Deprecated alias. Change to type"

[tool.ruff.mccabe]
max-complexity = 10

Expand Down
3 changes: 2 additions & 1 deletion type_stubs/wrapt.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__all__ = ["decorator"]

from typing import Any, Callable, TypeVar
from collections.abc import Callable
from typing import Any, TypeVar

_F = TypeVar("_F", bound=Callable[..., Any])

Expand Down

0 comments on commit 627305a

Please sign in to comment.