diff --git a/.basedpyright/baseline.json b/.basedpyright/baseline.json index db2bcf60..bf69c4b4 100644 --- a/.basedpyright/baseline.json +++ b/.basedpyright/baseline.json @@ -2403,86 +2403,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 4, - "endColumn": 11, - "lineCount": 1 - } - }, - { - "code": "reportUnknownParameterType", - "range": { - "startColumn": 12, - "endColumn": 20, - "lineCount": 1 - } - }, - { - "code": "reportMissingParameterType", - "range": { - "startColumn": 12, - "endColumn": 20, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 4, - "endColumn": 6, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 9, - "endColumn": 26, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 8, - "endColumn": 9, - "lineCount": 1 - } - }, - { - "code": "reportUnknownArgumentType", - "range": { - "startColumn": 17, - "endColumn": 19, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 8, - "endColumn": 13, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 8, - "endColumn": 9, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 11, - "endColumn": 18, - "lineCount": 1 - } - }, { "code": "reportUnknownParameterType", "range": { @@ -7461,22 +7381,6 @@ "lineCount": 1 } }, - { - "code": "reportAny", - "range": { - "startColumn": 4, - "endColumn": 8, - "lineCount": 1 - } - }, - { - "code": "reportAny", - "range": { - "startColumn": 28, - "endColumn": 32, - "lineCount": 1 - } - }, { "code": "reportAny", "range": { diff --git a/pyproject.toml b/pyproject.toml index 3845de3a..9f832a5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,12 +81,13 @@ extend-select = [ "FURB", ] extend-ignore = [ - "C90", # McCabe complexity - "multiple-spaces-before-operator", + "complex-structure", + "f-string", "missing-whitespace-around-arithmetic-operator", "module-import-not-at-top-of-file", + "multiple-spaces-before-operator", "printf-string-formatting", - "f-string", + "pytest-parameter-with-default-argument", # FIXME: This is a longer discussion... "non-empty-init-module", diff --git a/pytools/__init__.py b/pytools/__init__.py index 76fe63fc..19a823af 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -839,13 +839,13 @@ def wrapper(obj: T, *args: P.args, **kwargs: P.kwargs) -> R_co: result = function(obj, *args, **kwargs) if attribute_error: - object.__setattr__(obj, cache_dict_name, {key: result}) + object.__setattr__(obj, cache_dict_name, {key: result}) # ruff: ignore[unnecessary-dunder-call] return result getattr(obj, cache_dict_name)[key] = result return result def clear_cache(obj): - object.__delattr__(obj, cache_dict_name) + object.__delattr__(obj, cache_dict_name) # ruff: ignore[unnecessary-dunder-call] from functools import update_wrapper new_wrapper = update_wrapper(wrapper, function) @@ -1426,12 +1426,12 @@ def cartesian_product_sum(list1, list2): # {{{ elementary statistics -def average(iterable): +def average(iterable: Iterator[float]) -> float: """Return the average of the values in iterable. iterable may not be empty. """ - it = iterable.__iter__() + it = iter(iterable) try: s = next(it) diff --git a/pytools/datatable.py b/pytools/datatable.py index 494b5920..4476f82e 100644 --- a/pytools/datatable.py +++ b/pytools/datatable.py @@ -206,8 +206,8 @@ def without(indexable: tuple[str, ...], idx: int) -> tuple[str, ...]: this_key_idx = self.column_indices[column] other_key_idx = other_table.column_indices[other_column] - this_iter = self.data.__iter__() - other_iter = other_table.data.__iter__() + this_iter = iter(self.data) + other_iter = iter(other_table.data) result_columns = tuple(self.column_names[this_key_idx]) + \ without(tuple(self.column_names), this_key_idx) + \ diff --git a/pytools/persistent_dict.py b/pytools/persistent_dict.py index 591e4294..8ea851d8 100644 --- a/pytools/persistent_dict.py +++ b/pytools/persistent_dict.py @@ -224,6 +224,7 @@ def rec(self, key_hash: Hash, key: Any) -> Hash: if not isinstance(key, type): try: + # ruff: ignore[unnecessary-dunder-call] object.__setattr__(key, "_pytools_persistent_hash_digest", digest) except AttributeError: pass diff --git a/pytools/py_codegen.py b/pytools/py_codegen.py index aea63ea3..da568388 100644 --- a/pytools/py_codegen.py +++ b/pytools/py_codegen.py @@ -107,7 +107,7 @@ def _make_module( code_obj = compile( source_text.rstrip()+"\n", name, "exec") result_dict["__code__"] = code_obj - exec(code_obj, result_dict) # ruff:ignore[exec-builtin] + exec(code_obj, result_dict) return result_dict @@ -157,7 +157,7 @@ def _get_empty_module_dict(filename: str | None = None) -> dict[str, Any]: result_dict: dict[str, Any] = {} code_obj = compile("", filename, "exec") result_dict["__code__"] = code_obj - exec(code_obj, result_dict) # ruff:ignore[exec-builtin] + exec(code_obj, result_dict) return result_dict diff --git a/pytools/test/test_pytools.py b/pytools/test/test_pytools.py index bd56913f..a36ee1be 100644 --- a/pytools/test/test_pytools.py +++ b/pytools/test/test_pytools.py @@ -716,8 +716,14 @@ def test_strtobool(): with pytest.raises(ValueError): strtobool("tru") # spellchecker: disable-line + + with pytest.raises(ValueError): strtobool("fal") # spellchecker: disable-line + + with pytest.raises(ValueError): strtobool("xxx") + + with pytest.raises(ValueError): strtobool(".") assert strtobool(None, False) is False