@@ -28,6 +28,8 @@ docs = [
2828 " pydata-sphinx-theme" ,
2929 " sphinx"
3030]
31+ lint = [" black>=22.6.0" , " mdformat>0.7" , " ruff>=0.0.156" ]
32+ typing = [" mypy>=0.990" ]
3133
3234[tool .hatch .version ]
3335path = " traitlets/_version.py"
@@ -50,6 +52,26 @@ dependencies = ["coverage", "pytest-cov"]
5052test = " python -m pytest -vv --cov traitlets --cov-branch --cov-report term-missing:skip-covered {args}"
5153nowarn = " test -W default {args}"
5254
55+ [tool .hatch .envs .typing ]
56+ features = [" test" , " typing" ]
57+ dependencies = [" mypy>=0.990" ]
58+ [tool .hatch .envs .typing .scripts ]
59+ test = " mypy --install-types --non-interactive {args:.}"
60+
61+ [tool .hatch .envs .lint ]
62+ features = [" lint" ]
63+ [tool .hatch .envs .lint .scripts ]
64+ style = [
65+ " ruff {args:.}" ,
66+ " black --check --diff {args:.}" ,
67+ " mdformat --check {args:docs *.md}"
68+ ]
69+ fmt = [
70+ " black {args:.}" ,
71+ " ruff --fix {args:.}" ,
72+ " mdformat {args:docs *.md}"
73+ ]
74+
5375[tool .mypy ]
5476check_untyped_defs = true
5577disallow_any_generics = true
@@ -115,27 +137,69 @@ exclude_lines = [
115137" @(abc\\ .)?abstractmethod" ,
116138]
117139
118- [tool .flake8 ]
119- ignore = " E501, W503, E402"
120- builtins = " c, get_config"
121- exclude = [
122- " .cache" ,
123- " .github" ,
124- " docs" ,
125- " setup.py" ,
140+ [tool .black ]
141+ line-length = 100
142+ skip-string-normalization = true
143+ target-version = [" py37" ]
144+
145+ [tool .ruff ]
146+ target-version = " py37"
147+ line-length = 100
148+ select = [
149+ " A" , " B" , " C" , " E" , " F" , " FBT" , " I" , " N" , " Q" , " RUF" , " S" , " T" ,
150+ " UP" , " W" , " YTT" ,
126151]
127- enable-extensions = " G"
128- extend-ignore = [
129- " G001" , " G002" , " G004" , " G200" , " G201" , " G202" ,
130- # black adds spaces around ':'
131- " E203" ,
152+ ignore = [
153+ # Allow non-abstract empty methods in abstract base classes
154+ " B027" ,
155+ # Ignore McCabe complexity
156+ " C901" ,
157+ # Allow boolean positional values in function calls, like `dict.get(... True)`
158+ " FBT003" ,
159+ # Use of `assert` detected
160+ " S101" ,
161+ # Line too long
162+ " E501" ,
163+ # Relative imports are banned
164+ " I252" ,
165+ # Boolean ... in function definition
166+ " FBT001" , " FBT002" ,
167+ # Module level import not at top of file
168+ " E402" ,
169+ # A001/A002/A003 .. is shadowing a python builtin
170+ " A001" , " A002" , " A003" ,
171+ # Possible hardcoded password
172+ " S105" , " S106" ,
173+ # Q000 Single quotes found but double quotes preferred
174+ " Q000" ,
175+ # N806 Variable `B` in function should be lowercase
176+ " N806" ,
177+ # T201 `print` found
178+ " T201" ,
179+ # N802 Function name `CreateWellKnownSid` should be lowercase
180+ " N802" , " N803" ,
181+ # C408 Unnecessary `dict` call (rewrite as a literal)
182+ " C408" ,
183+ # N801 Class name `directional_link` should use CapWords convention
184+ " N801" ,
132185]
133- per-file-ignores = [
134- # B011: Do not call assert False since python -O removes these calls
135- # F841 local variable 'foo' is assigned to but never used
136- " traitlets/tests/*: B011" , " F841" ,
137- # F401 'foo' imported but unused
138- # F403 'from foo import *' used; unable to detect undefined names
139- " traitlets/__init__.py: F401" , " F403" ,
140- " traitlets/*/__init__.py: F401" , " F403" ,
186+ unfixable = [
187+ # Don't touch print statements
188+ " T201" ,
189+ # Don't touch noqa lines
190+ " RUF100" ,
141191]
192+
193+ [tool .ruff .per-file-ignores ]
194+ # B011 Do not call assert False since python -O removes these calls
195+ # F841 local variable 'foo' is assigned to but never used
196+ # C408 Unnecessary `dict` call
197+ # E402 Module level import not at top of file
198+ # T201 `print` found
199+ # B007 Loop control variable `i` not used within the loop body.
200+ # N802 Function name `assertIn` should be lowercase
201+ # F841 Local variable `t` is assigned to but never used
202+ "traitlets/tests/*" = [" B011" , " F841" , " C408" , " E402" , " T201" , " B007" , " N802" , " F841" ]
203+ # F401 `_version.__version__` imported but unused
204+ # F403 `from .traitlets import *` used; unable to detect undefined names
205+ "traitlets/*__init__.py" = [" F401" , " F403" ]
0 commit comments