Skip to content

Commit

Permalink
exclude cloudpickle from linting
Browse files Browse the repository at this point in the history
  • Loading branch information
samster25 committed Apr 15, 2024
1 parent 48eff98 commit 649d736
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
2 changes: 1 addition & 1 deletion daft/pickle/cloudpickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions daft/pickle/cloudpickle_fast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 649d736

Please sign in to comment.