diff --git a/deptry/cli_defaults.py b/deptry/cli_defaults.py index 31170615..6a789b5e 100644 --- a/deptry/cli_defaults.py +++ b/deptry/cli_defaults.py @@ -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, diff --git a/deptry/dependency_getter/requirements_txt.py b/deptry/dependency_getter/requirements_txt.py index 069f418c..662268f8 100644 --- a/deptry/dependency_getter/requirements_txt.py +++ b/deptry/dependency_getter/requirements_txt.py @@ -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]: @@ -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) diff --git a/deptry/notebook_import_extractor.py b/deptry/notebook_import_extractor.py index de605e3f..904b89ae 100644 --- a/deptry/notebook_import_extractor.py +++ b/deptry/notebook_import_extractor.py @@ -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 diff --git a/deptry/python_file_finder.py b/deptry/python_file_finder.py index ea227a25..981320eb 100644 --- a/deptry/python_file_finder.py +++ b/deptry/python_file_finder.py @@ -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 diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index 39c9c639..1a9094e5 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -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"} diff --git a/tests/test_json_writer.py b/tests/test_json_writer.py index 704d9055..5e0e567c 100644 --- a/tests/test_json_writer.py +++ b/tests/test_json_writer.py @@ -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"