Skip to content

Commit

Permalink
Remove dependency to setoptconf
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Oct 17, 2024
1 parent 80c2cb0 commit cf82c0a
Show file tree
Hide file tree
Showing 12 changed files with 461 additions and 512 deletions.
155 changes: 138 additions & 17 deletions poetry.lock

Large diffs are not rendered by default.

26 changes: 11 additions & 15 deletions prospector/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
import sys
from pathlib import Path
from typing import Dict, List, Union
from typing import Dict, List, Tuple, Union

try: # Python >= 3.11
import re._constants as sre_constants
Expand All @@ -27,8 +27,8 @@ class ProspectorConfig:
# is a config object and its sole purpose is to hold many properties!

def __init__(self, workdir: Path = None):
self.config, self.arguments = self._configure_prospector()
self.paths = self._get_work_path(self.config, self.arguments)
self.config = self._configure_prospector()
self.paths = self._get_work_path(self.config)
self.explicit_file_mode = all(p.is_file for p in self.paths)
self.workdir = workdir or Path.cwd()

Expand Down Expand Up @@ -106,23 +106,19 @@ def get_output_report(self):

return output_report

def _configure_prospector(self):
# first we will configure prospector as a whole
mgr = cfg.build_manager()
config = mgr.retrieve(*cfg.build_default_sources())
return config, mgr.arguments
def _configure_prospector(self) -> cfg.Config:
# First we will configure prospector as a whole
return cfg.get_config()

def _get_work_path(self, config, arguments) -> List[Path]:
def _get_work_path(self, config) -> List[Path]:
# Figure out what paths we're prospecting
if config["path"]:
paths = [Path(self.config["path"])]
elif arguments["checkpath"]:
paths = [Path(p) for p in arguments["checkpath"]]
if config.path:
paths = [Path(self.config.path)]
else:
paths = [Path.cwd()]
return [p.resolve() for p in paths]

def _get_profile(self, workdir: Path, config):
def _get_profile(self, workdir: Path, config: cfg.Config) -> Tuple[ProspectorProfile, str]:
# Use the specified profiles
profile_provided = False
if len(config.profiles) > 0:
Expand Down Expand Up @@ -168,7 +164,7 @@ def _get_profile(self, workdir: Path, config):

# Use the strictness profile only if no profile has been given
if config.strictness is not None and config.strictness:
cmdline_implicit.append("strictness_%s" % config.strictness)
cmdline_implicit.append("strictness_%s" % config.strictness.value)
strictness = config.strictness

# the profile path is
Expand Down
Loading

0 comments on commit cf82c0a

Please sign in to comment.