Skip to content

Commit 24a2450

Browse files
authored
More Typing Adoption (#873)
1 parent 0d27f7d commit 24a2450

34 files changed

Lines changed: 3586 additions & 3357 deletions

pyproject.toml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ nowarn = "test -W default {args}"
5656
[tool.hatch.envs.typing]
5757
features = ["test"]
5858
[tool.hatch.envs.typing.scripts]
59-
test = "mypy --install-types --non-interactive {args:.}"
59+
test = "mypy --install-types --non-interactive {args}"
6060

6161
[tool.hatch.envs.lint]
6262
dependencies = ["black==23.3.0", "mdformat>0.7", "ruff==0.0.281"]
@@ -74,6 +74,7 @@ fmt = [
7474
]
7575

7676
[tool.mypy]
77+
files = "traitlets"
7778
python_version = "3.8"
7879
check_untyped_defs = true
7980
disallow_any_generics = true
@@ -97,7 +98,7 @@ exclude = ["examples/docs/configs", "traitlets/tests/test_typing.py"]
9798
[tool.pytest.ini_options]
9899
addopts = "--durations=10 -ra --showlocals --doctest-modules --color yes --ignore examples/docs/configs"
99100
testpaths = [
100-
"traitlets",
101+
"tests",
101102
"examples",
102103
]
103104
filterwarnings = [
@@ -153,10 +154,18 @@ target-version = ["py37"]
153154
target-version = "py37"
154155
line-length = 100
155156
select = [
156-
"A", "B", "C", "E", "F", "FBT", "I", "N", "Q", "RUF", "S", "T",
157+
"A", "ANN", "B", "C", "E", "F", "FBT", "I", "N", "Q", "RUF", "S", "T",
157158
"UP", "W", "YTT",
158159
]
159160
ignore = [
161+
# Dynamically typed expressions (typing.Any) are disallowed in `key`
162+
"ANN401",
163+
# Missing type annotation for `self` in method
164+
"ANN101",
165+
# Missing type annotation for `cls` in classmethod
166+
"ANN102",
167+
# ANN202 Missing return type annotation for private function
168+
"ANN202",
160169
# Allow non-abstract empty methods in abstract base classes
161170
"B027",
162171
# Ignore McCabe complexity
@@ -211,11 +220,13 @@ unfixable = [
211220
# N802 Function name `assertIn` should be lowercase
212221
# F841 Local variable `t` is assigned to but never used
213222
# B018 Found useless expression
214-
# S301 `pickle` and modules that wrap...
215-
"traitlets/tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "F841",
223+
# S301 `pickle` and modules that wrap..."
224+
"tests/*" = ["ANN", "B011", "F841", "C408", "E402", "T201", "B007", "N802", "F841",
216225
"B018", "S301"]
217226
# B003 Assigning to os.environ doesn't clear the environment
218-
"traitlets/config/tests/*" = ["B003", "B018", "S301"]
227+
"tests/config/*" = ["B003", "B018", "S301"]
219228
# F401 `_version.__version__` imported but unused
220229
# F403 `from .traitlets import *` used; unable to detect undefined names
221230
"traitlets/*__init__.py" = ["F401", "F403"]
231+
"docs/*" = ["ANN"]
232+
"examples/*" = ["ANN"]

traitlets/config/tests/test_application.py renamed to tests/config/test_application.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def test_raise_on_bad_config(self):
601601
with self.assertRaises(SyntaxError):
602602
app.load_config_file(name, path=[td])
603603

604-
def test_subcommands_instanciation(self):
604+
def test_subcommands_instantiation(self):
605605
"""Try all ways to specify how to create sub-apps."""
606606
app = Root.instance()
607607
app.parse_command_line(["sub1"])
@@ -694,7 +694,7 @@ class App(Application):
694694

695695
class Root(Application):
696696
subcommands = {
697-
"sub1": ("traitlets.config.tests.test_application.Sub1", "import string"),
697+
"sub1": ("tests.config.test_application.Sub1", "import string"),
698698
}
699699

700700

File renamed without changes.

traitlets/config/tests/test_configurable.py renamed to tests/config/test_configurable.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from pytest import mark
1010

11+
from tests._warnings import expected_warnings
1112
from traitlets.config.application import Application
1213
from traitlets.config.configurable import Configurable, LoggingConfigurable, SingletonConfigurable
1314
from traitlets.config.loader import Config
@@ -26,8 +27,6 @@
2627
)
2728
from traitlets.utils.warnings import _deprecations_shown
2829

29-
from ...tests._warnings import expected_warnings
30-
3130

3231
class MyConfigurable(Configurable):
3332
a = Integer(1, help="The integer a.").tag(config=True)

0 commit comments

Comments
 (0)