Skip to content

Commit

Permalink
chore: run pre-commit run pyupgrade -a
Browse files Browse the repository at this point in the history
  • Loading branch information
mkniewallner committed Nov 5, 2022
1 parent 911103f commit 9cd2e41
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion deptry/cli_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"ignore_missing": (),
"ignore_transitive": (),
"ignore_misplaced_dev": (),
"exclude": ("venv", "\.venv", "tests", "\.git", "setup.py"),
"exclude": ("venv", r"\.venv", "tests", r"\.git", "setup.py"),
"extend_exclude": (),
"ignore_notebooks": False,
"skip_obsolete": False,
Expand Down
6 changes: 3 additions & 3 deletions deptry/dependency_getter/requirements_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _check_if_dependency_is_conditional(line: str) -> bool:

@staticmethod
def _line_is_url(line: str) -> Optional[Match[str]]:
return re.search("^(http|https|git\+https)", line)
return re.search(r"^(http|https|git\+https)", line)

@staticmethod
def _extract_name_from_url(line: str) -> Optional[str]:
Expand All @@ -114,12 +114,12 @@ def _extract_name_from_url(line: str) -> Optional[str]:
return match.group(1)

# for url like git+https://github.com/name/python-module.git@0d6dc38d58
match = re.search("\/((?:(?!\/).)*?)\.git", line)
match = re.search(r"\/((?:(?!\/).)*?)\.git", line)
if match:
return match.group(1)

# for url like https://github.com/urllib3/urllib3/archive/refs/tags/1.26.8.zip
match = re.search("\/((?:(?!\/).)*?)\/archive\/", line)
match = re.search(r"\/((?:(?!\/).)*?)\/archive\/", line)
if match:
return match.group(1)

Expand Down
2 changes: 1 addition & 1 deletion deptry/notebook_import_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def extract(self, path_to_ipynb: Path) -> List[str]:

@staticmethod
def _read_ipynb_file(path_to_ipynb: Path) -> Dict[str, Any]:
with open(path_to_ipynb, "r") as f:
with open(path_to_ipynb) as f:
notebook: Dict[str, Any] = json.load(f)
return notebook

Expand Down
2 changes: 1 addition & 1 deletion deptry/python_file_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_all_python_files_in(self, directory: Path) -> List[Path]:
py_regex = re.compile(r".*\.py$") if self.ignore_notebooks else re.compile(r".*\.py$|.*\.ipynb$")

for root, dirs, files in os.walk(directory, topdown=True):
root_without_trailing_dotslash = re.sub("^\./", "", root)
root_without_trailing_dotslash = re.sub(r"^\./", "", root)
if self.exclude and ignore_regex.match(root_without_trailing_dotslash):
dirs[:] = []
continue
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_cli_with_json_output(dir_with_venv_installed):

# assert that there is json output
subprocess.run(shlex.split("poetry run deptry . -o deptry.json"), capture_output=True, text=True)
with open("deptry.json", "r") as f:
with open("deptry.json") as f:
data = json.load(f)
assert set(data["obsolete"]) == {"isort", "requests"}
assert set(data["missing"]) == {"white"}
Expand Down
2 changes: 1 addition & 1 deletion tests/test_json_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def test_simple(tmp_path):
with run_within_dir(tmp_path):
JsonWriter(json_output="output.json").write(issues={"one": "two", "three": "four"})

with open("output.json", "r") as f:
with open("output.json") as f:
data = json.load(f)

assert data["one"] == "two"
Expand Down

0 comments on commit 9cd2e41

Please sign in to comment.