Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid shadowing builtins #303

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pins/boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,16 @@ def _pin_store(
versioned: bool | None = None,
created: datetime | None = None,
) -> Meta:
if type == "feather":
_type = type
if _type == "feather":
warn_deprecated(
'Writing pin type "feather" is unsupported. Switching type to "arrow".'
" This produces the exact same behavior, and also works with R pins."
' Please switch to pin_write using type="arrow".'
)
type = "arrow"
_type = "arrow"

if type == "file":
if _type == "file":
# the file type makes the name of the data the exact filename, rather
# than the pin name + a suffix (e.g. my_pin.csv).
if isinstance(x, (tuple, list)) and len(x) == 1:
Expand All @@ -254,7 +255,7 @@ def _pin_store(
tmp_dir,
x,
pin_name,
type,
_type,
title,
description,
metadata,
Expand Down
8 changes: 4 additions & 4 deletions pins/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def __call__(self, path: str) -> str:
if self.hash_prefix is not None:
# optionally make the name relative to a parent path
# using the hash of parent path as a prefix, to flatten a bit
hash = Path(path).relative_to(Path(self.hash_prefix))
return hash
_hash = Path(path).relative_to(Path(self.hash_prefix))
return _hash

else:
raise NotImplementedError()
Expand Down Expand Up @@ -99,8 +99,8 @@ def __call__(self, path):
# the main change in this function is that, for same_name, it returns
# the full path
# change pin path of form <user>/<content> to <user>+<content>
hash = path.replace("/", "+", 1)
return hash
_hash = path.replace("/", "+", 1)
return _hash


class PinsCache(SimpleCacheFileSystem):
Expand Down
6 changes: 3 additions & 3 deletions pins/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def warn_deprecated(msg):

def hash_name(path, same_name):
if same_name:
hash = os.path.basename(path)
_hash = os.path.basename(path)
else:
hash = hashlib.sha256(path.encode()).hexdigest()
return hash
_hash = hashlib.sha256(path.encode()).hexdigest()
return _hash


class ExtendMethodDoc:
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ select = [
"I", # Import sorting
"UP", # Upgrade to latest supported Python syntax
"W", # Style
"A", # Don't shadow built-ins
]
ignore = [
"E501", # Line too long
"A002", # The pins interface includes builtin names in args, e.g. hash, id, etc.
]
Loading