Skip to content

Commit 141cf48

Browse files
committed
Further cut down on ruff exceptions.
1 parent f13ccd5 commit 141cf48

File tree

83 files changed

+800
-491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+800
-491
lines changed

conftest.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,17 @@ def pytest_addoption(parser):
2424

2525
@pytest.fixture
2626
def backend(request) -> Literal["numpy", "jax"]:
27-
backend = request.config.getoption("--backend")
28-
return backend
27+
return request.config.getoption("--backend")
2928

3029

3130
@pytest.fixture
3231
def xnp(request) -> ModuleType:
33-
backend = request.config.getoption("--backend")
34-
return ttsim_xnp(backend)
32+
return ttsim_xnp(request.config.getoption("--backend"))
3533

3634

3735
@pytest.fixture
3836
def dnp(request) -> ModuleType:
39-
backend = request.config.getoption("--backend")
40-
return ttsim_dnp(backend)
37+
return ttsim_dnp(request.config.getoption("--backend"))
4138

4239

4340
@pytest.fixture(autouse=True)

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# -- Project information -----------------------------------------------------
1515

1616
project = "GETTSIM"
17-
copyright = f"2019-{datetime.today().year}, GETTSIM team" # noqa: A001
17+
copyright = f"2019-{datetime.today().year}, GETTSIM team" # noqa: A001, DTZ002
1818
author = "GETTSIM team"
1919
release = "0.7.0"
2020
version = ".".join(release.split(".")[:2])
@@ -122,7 +122,7 @@
122122
"**": [
123123
"relations.html", # needs 'show_related': True theme option to display
124124
"searchbox.html",
125-
]
125+
],
126126
}
127127

128128
# Napoleon settings

pixi.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -197,48 +197,28 @@ unsafe-fixes = false
197197
[tool.ruff.lint]
198198
select = ["ALL"]
199199
extend-ignore = [
200-
"ICN001", # numpy should be np, but different convention here.
201-
# Docstrings
202-
"D103", # missing docstring in public function
203-
"D107",
204-
"D203",
205-
"D212",
206-
"D213",
207-
"D402",
208-
"D413",
209-
"D415",
210-
"D416",
211-
"D417",
200+
"COM812", # Avoid conflicts with ruff-format
201+
"EM101", # Exception must not use a string literal
202+
"EM102", # Exception must not use an f-string literal
212203
"F722", # https://docs.kidger.site/jaxtyping/faq/#flake8-or-ruff-are-throwing-an-error
213204
"FBT001", # Boolean-typed positional argument in function definition
205+
"FIX002", # Line contains TODO -- Use stuff from TD area.
206+
"ICN001", # numpy should be np, but different convention here.
214207
"ISC001", # Avoid conflicts with ruff-format
215208
"N999", # Allow non-ASCII characters in file names.
216209
"PLC2401", # Allow non-ASCII characters in variable names.
217210
"PLC2403", # Allow non-ASCII function names for imports.
218211
"PLR0913", # Allow too many arguments in function definitions.
219-
"FIX002", # Line contains TODO -- Use stuff from TD area.
220-
"TRY003", # Avoid specifying long messages outside the exception class
221212
"PLR5501", # elif not supported by vectorization converter for Jax
222-
"EM101", # Exception must not use a string literal
223-
"EM102", # Exception must not use an f-string literal
224-
# Others.
225-
226-
"E731", # do not assign a lambda expression, use a def
227-
"RET", # unnecessary elif or else statements after return, raise, continue, ...
228-
"S324", # Probable use of insecure hash function.
229-
"COM812", # trailing comma missing, but black takes care of that
230-
"PT007", # wrong type in parametrize, gave false positives
231-
"DTZ001", # use of `datetime.datetime()` without `tzinfo` argument is not allowed
232-
"DTZ002", # use of `datetime.datetime.today()` is not allowed
233-
"PT012", # `pytest.raises()` block should contain a single simple statement
234-
213+
"TRY003", # Avoid specifying long messages outside the exception class
235214

236215
# Ignored during transition phase
237216
# ======================================
238217
"D", # docstrings
239-
"PLR2004", # Magic values used in comparison
240218
"INP001", # implicit namespace packages without init.
219+
"PLR2004", # Magic values used in comparison
241220
"PT006", # Allows only lists of tuples in parametrize, even if single argument
221+
"PT007", # wrong type in parametrize
242222
"S101", # use of asserts outside of tests
243223

244224
]
@@ -248,17 +228,17 @@ exclude = []
248228
"conftest.py" = ["ANN"]
249229
"docs/**/*.ipynb" = ["T201"]
250230
# Mostly things vectorization can't handle
251-
"src/_gettsim/*" = ["E501", "PLR1714", "PLR1716", "E721", "SIM108"]
231+
"src/_gettsim/*" = ["E501", "PLR1714", "PLR1716", "E721", "SIM108", "RET"]
252232
# All tests return None and use asserts
253233
"src/_gettsim_tests/**/*.py" = ["ANN", "S101"]
254234
"src/ttsim/interface_dag_elements/specialized_environment.py" = ["E501"]
255235
"src/ttsim/interface_dag_elements/fail_if.py" = ["E501"]
256236
"src/ttsim/interface_dag_elements/typing.py" = ["PGH", "PLR", "SIM114"]
257237
# Mostly things vectorization can't handle
258-
"tests/ttsim/mettsim/**/*.py" = ["PLR1714", "PLR1716", "E721", "SIM108"]
238+
"tests/ttsim/mettsim/**/*.py" = ["PLR1714", "PLR1716", "E721", "SIM108", "RET"]
239+
"tests/ttsim/tt_dag_elements/test_vectorization.py" = ["PLR1714", "PLR1716", "E721", "SIM108", "RET"]
259240
# All tests return None and use asserts
260241
"tests/ttsim/**/*.py" = ["ANN", "S101"]
261-
"tests/ttsim/tt_dag_elements/test_vectorization.py" = ["PLR1714", "PLR1716", "E721", "SIM108"]
262242
"tests/ttsim/test_failures.py" = ["E501"]
263243
# TODO: remove once ported nicely
264244
"src/ttsim/stale_code_storage.py" = ["ALL"]
@@ -298,20 +278,12 @@ disallow_untyped_defs = false
298278
ignore_errors = true
299279

300280
[[tool.mypy.overrides]]
301-
module = [
302-
"tests.*",
303-
]
304-
disable_error_code = [
305-
"no-untyped-def", # All tests return None, don't clutter source code.
306-
]
281+
module = ["tests.*",]
282+
disable_error_code = ["no-untyped-def"] # All tests return None, don't clutter source code.
307283

308284
[[tool.mypy.overrides]]
309-
module = [
310-
"src._gettsim_tests.*",
311-
]
312-
disable_error_code = [
313-
"no-untyped-def", # All tests return None, don't clutter source code.
314-
]
285+
module = ["src._gettsim_tests.*",]
286+
disable_error_code = ["no-untyped-def"] # All tests return None, don't clutter source code.
315287

316288
[tool.check-manifest]
317289
ignore = ["src/_gettsim/_version.py"]

src/_gettsim/arbeitslosengeld_2/freibeträge_vermögen.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def vermögensfreibetrag_in_karenzzeit_bg(
7575

7676

7777
@policy_function(
78-
start_date="2005-01-01", end_date="2022-12-31", leaf_name="vermögensfreibetrag_bg"
78+
start_date="2005-01-01",
79+
end_date="2022-12-31",
80+
leaf_name="vermögensfreibetrag_bg",
7981
)
8082
def vermögensfreibetrag_bg_bis_2022(
8183
grundfreibetrag_vermögen_bg: float,

src/_gettsim/arbeitslosengeld_2/kindergeldübertrag.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@
1414

1515
@agg_by_p_id_function(start_date="2005-01-01", agg_type=AggType.SUM)
1616
def kindergeldübertrag_m(
17-
differenz_kindergeld_kindbedarf_m: float, kindergeld__p_id_empfänger: int, p_id: int
17+
differenz_kindergeld_kindbedarf_m: float,
18+
kindergeld__p_id_empfänger: int,
19+
p_id: int,
1820
) -> float:
1921
pass
2022

2123

2224
@policy_function(
23-
start_date="2005-01-01", end_date="2022-12-31", leaf_name="kindergeld_pro_kind_m"
25+
start_date="2005-01-01",
26+
end_date="2022-12-31",
27+
leaf_name="kindergeld_pro_kind_m",
2428
)
2529
def _mean_kindergeld_per_child_gestaffelt_m(
2630
kindergeld__betrag_m: float,

src/_gettsim/arbeitslosengeld_2/regelbedarf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ def mehrbedarf_alleinerziehend_m(
7676

7777

7878
@policy_function(
79-
start_date="2005-01-01", end_date="2010-12-31", leaf_name="kindersatz_m"
79+
start_date="2005-01-01",
80+
end_date="2010-12-31",
81+
leaf_name="kindersatz_m",
8082
)
8183
def kindersatz_m_anteilsbasiert(
8284
alter: int,

src/_gettsim/einkommensteuer/abzüge/alleinerziehend.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
@policy_function(end_date="2014-12-31", leaf_name="alleinerziehend_betrag_y")
99
def alleinerziehend_betrag_y_pauschal(
10-
einkommensteuer__alleinerziehend_sn: bool, alleinerziehendenfreibetrag_basis: float
10+
einkommensteuer__alleinerziehend_sn: bool,
11+
alleinerziehendenfreibetrag_basis: float,
1112
) -> float:
1213
"""Calculate tax deduction allowance for single parents until 2014"""
1314
if einkommensteuer__alleinerziehend_sn:

src/_gettsim/einkommensteuer/abzüge/alter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,12 @@ def get_consecutive_int_1d_lookup_table_with_filled_up_tails(
149149
"Dictionary keys must be consecutive integers."
150150
)
151151
consecutive_dict_start = dict.fromkeys(
152-
range(left_tail_key, min_key_in_spec), raw[min_key_in_spec]
152+
range(left_tail_key, min_key_in_spec),
153+
raw[min_key_in_spec],
153154
)
154155
consecutive_dict_end = dict.fromkeys(
155-
range(max_key_in_spec + 1, right_tail_key + 1), raw[max_key_in_spec]
156+
range(max_key_in_spec + 1, right_tail_key + 1),
157+
raw[max_key_in_spec],
156158
)
157159
return get_consecutive_int_1d_lookup_table_param_value(
158160
raw={**consecutive_dict_start, **raw, **consecutive_dict_end},

src/_gettsim/einkommensteuer/abzüge/sonderausgaben.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
@agg_by_p_id_function(agg_type=AggType.SUM)
1414
def kinderbetreuungskosten_elternteil_m(
15-
kinderbetreuungskosten_m: float, p_id_kinderbetreuungskostenträger: int, p_id: int
15+
kinderbetreuungskosten_m: float,
16+
p_id_kinderbetreuungskostenträger: int,
17+
p_id: int,
1618
) -> float:
1719
pass
1820

0 commit comments

Comments
 (0)