Skip to content

Commit

Permalink
refactor: add "flake8-simplify" plugin and simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
sisp authored and yajo committed Sep 1, 2022
1 parent 13fddd9 commit 84f5644
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
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

0 comments on commit 84f5644

Please sign in to comment.