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

Fix PTH103 os.makedirs() should be replaced by Path.mkdir #4791

Merged
merged 1 commit into from
Oct 31, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions backend/infrahub/git/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ async def create_locally(
log.warning(f"Found an existing file at {self.directory_root}, deleted it", repository=self.name)

# Initialize directory structure
os.makedirs(self.directory_root)
os.makedirs(self.directory_branches)
os.makedirs(self.directory_commits)
os.makedirs(self.directory_temp)
Path(self.directory_root).mkdir(parents=True)
Path(self.directory_branches).mkdir(parents=True)
Path(self.directory_commits).mkdir(parents=True)
Path(self.directory_temp).mkdir(parents=True)

try:
repo = Repo.clone_from(self.location, self.directory_default)
Expand Down
4 changes: 3 additions & 1 deletion backend/infrahub/git/directory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path

from infrahub import config
from infrahub.log import get_logger
Expand All @@ -25,7 +26,8 @@ def initialize_repositories_directory() -> bool:
"""
repos_dir = get_repositories_directory()
if not os.path.isdir(repos_dir):
os.makedirs(repos_dir)
Path(repos_dir).mkdir(parents=True)

log.debug(f"Initialized the repositories_directory at {repos_dir}")
return True

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ ignore = [
"PLW1508", # Invalid type for environment variable default; expected `str` or `None`
"PTH100", # `os.path.abspath()` should be replaced by `Path.resolve()`
"PTH102", # `os.mkdir()` should be replaced by `Path.mkdir()`
"PTH103", # `os.makedirs()` should be replaced by `Path.mkdir(parents=True)`
"PTH107", # `os.remove()` should be replaced by `Path.unlink()`
"PTH108", # `os.unlink()` should be replaced by `Path.unlink()`
"PTH109", # `os.getcwd()` should be replaced by `Path.cwd()`
Expand Down
Loading