diff --git a/.ruff.toml b/.ruff.toml index 18a03ebabb..8e37a84b9a 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -14,6 +14,7 @@ quote-style = "double" skip-magic-trailing-comma = false [lint] +exclude = ["daft/pickle/cloudpickle.py", "daft/pickle/cloudpickle_fast.py"] extend-select = [ "UP", # pyupgrade "LOG", # flake8-logging @@ -29,7 +30,5 @@ ignore = [ [lint.per-file-ignores] # Do not enforce usage and import order rules in init files "__init__.py" = ["E402", "F401", "I"] -# ignore vendored cloudpickle old python code -"daft/pickle/cloudpickle*" = ["UP036"] # Allow wild imports in conftest "tests/conftest.py" = ["F405", "E402", "F403"] diff --git a/daft/pickle/cloudpickle.py b/daft/pickle/cloudpickle.py index 4e49deb51c..7f30a0e42a 100644 --- a/daft/pickle/cloudpickle.py +++ b/daft/pickle/cloudpickle.py @@ -200,7 +200,7 @@ def _whichmodule(obj, name): - Errors arising during module introspection are ignored, as those errors are considered unwanted side effects. """ - if sys.version_info[:2] < (3, 7) and isinstance(obj, typing.TypeVar): # pragma: no branch + if sys.version_info[:2] < (3, 7) and isinstance(obj, typing.TypeVar): # pragma: no branch # noqa # Workaround bug in old Python versions: prior to Python 3.7, # T.__module__ would always be set to "typing" even when the TypeVar T # would be defined in a different module. diff --git a/daft/pickle/cloudpickle_fast.py b/daft/pickle/cloudpickle_fast.py index fa5937b69f..00c66f3f97 100644 --- a/daft/pickle/cloudpickle_fast.py +++ b/daft/pickle/cloudpickle_fast.py @@ -494,7 +494,7 @@ def _dynamic_class_reduce(obj): def _class_reduce(obj): """Select the reducer depending on the dynamic nature of the class obj""" - if obj is type(None): + if obj is type(None): # noqa return type, (None,) elif obj is type(Ellipsis): return type, (Ellipsis,) @@ -777,7 +777,7 @@ def reducer_override(self, obj): reducers, such as Exceptions. See https://github.com/cloudpipe/cloudpickle/issues/248 """ - if sys.version_info[:2] < (3, 7) and _is_parametrized_type_hint(obj): # pragma: no branch + if sys.version_info[:2] < (3, 7) and _is_parametrized_type_hint(obj): # noqa # pragma: no branch return (_create_parametrized_type_hint, parametrized_type_hint_getinitargs(obj)) t = type(obj) try: @@ -827,7 +827,7 @@ def save_global(self, obj, name=None, pack=struct.pack): The name of this method is somewhat misleading: all types get dispatched here. """ - if obj is type(None): + if obj is type(None): # noqa return self.save_reduce(type, (None,), obj=obj) elif obj is type(Ellipsis): return self.save_reduce(type, (Ellipsis,), obj=obj) @@ -836,7 +836,7 @@ def save_global(self, obj, name=None, pack=struct.pack): elif obj in _BUILTIN_TYPE_NAMES: return self.save_reduce(_builtin_type, (_BUILTIN_TYPE_NAMES[obj],), obj=obj) - if sys.version_info[:2] < (3, 7) and _is_parametrized_type_hint(obj): # pragma: no branch + if sys.version_info[:2] < (3, 7) and _is_parametrized_type_hint(obj): # noqa # pragma: no branch # Parametrized typing constructs in Python < 3.7 are not # compatible with type checks and ``isinstance`` semantics. For # this reason, it is easier to detect them using a