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

refactor: add "flake8-simplify" plugin and simplify code #776

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
extend-ignore = W503,E203,E501,D100,D101,D102,D103,D104,D105,D107
extend-ignore = W503,E203,E501,D100,D101,D102,D103,D104,D105,D107,SIM117
max-complexity = 20
max-line-length = 88
12 changes: 6 additions & 6 deletions copier/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,8 @@ def _render_allowed(
assert not dst_relpath.is_absolute()
assert not expected_contents or not is_dir, "Dirs cannot have expected content"
dst_abspath = Path(self.subproject.local_abspath, dst_relpath)
if dst_relpath != Path("."):
if self.match_exclude(dst_relpath):
return False
if dst_relpath != Path(".") and self.match_exclude(dst_relpath):
return False
try:
previous_content = dst_abspath.read_bytes()
except FileNotFoundError:
Expand All @@ -291,9 +290,10 @@ def _render_allowed(
return True
except (IsADirectoryError, PermissionError) as error:
# HACK https://bugs.python.org/issue43095
if isinstance(error, PermissionError):
if not (error.errno == 13 and platform.system() == "Windows"):
raise
if isinstance(error, PermissionError) and not (
error.errno == 13 and platform.system() == "Windows"
):
raise
if is_dir:
printf(
"identical",
Expand Down
2 changes: 1 addition & 1 deletion copier/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def is_git_repo_root(path: StrOrPath) -> bool:
"""Indicate if a given path is a git repo root directory."""
try:
with local.cwd(Path(path, ".git")):
return bool(git("rev-parse", "--is-inside-git-dir").strip() == "true")
return git("rev-parse", "--is-inside-git-dir").strip() == "true"
except OSError:
return False

Expand Down
33 changes: 31 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ flake8 = ">=4.0.1"
flake8-bugbear = ">=22.1.11"
flake8-comprehensions = ">=3.8.0"
flake8-debugger = ">=4.0.0"
flake8-simplify = ">=0.19.3"
isort = ">=5.10.1"
mypy = ">=0.931"
pexpect = ">=4.8.0"
Expand Down