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 22, 2024
1 parent 4759399 commit 614c09d
Show file tree
Hide file tree
Showing 12 changed files with 454 additions and 504 deletions.
153 changes: 137 additions & 16 deletions poetry.lock

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions prospector/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
import re
import sys
from pathlib import Path
<<<<<<< HEAD
from typing import Any, Callable, Optional, Union

import setoptconf.config

from prospector.finder import FileFinder
||||||| parent of d495b9d (Remove dependency to setoptconf)
from typing import Dict, List, Union
=======
from typing import Dict, List, Tuple, Union
>>>>>>> d495b9d (Remove dependency to setoptconf)

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

def __init__(self, workdir: Optional[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 @@ -110,25 +116,19 @@ def get_output_report(self) -> list[tuple[str, list[str]]]:

return output_report

def _configure_prospector(self) -> tuple[setoptconf.config.Configuration, dict[str, str]]:
# 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: -> tuple[setoptconf.config.Configuration, dict[str, str]]:
# First we will configure prospector as a whole
return cfg.get_config()

def _get_work_path(self, config: setoptconf.config.Configuration, arguments: dict[str, str]) -> list[Path]:
def _get_work_path(self, config: setoptconf.config.Configuration) -> 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: setoptconf.config.Configuration
) -> tuple[ProspectorProfile, Optional[str]]:
def _get_profile(self, workdir: Path, config: cfg.Config) -> Tuple[ProspectorProfile, Optional[str]]:
# Use the specified profiles
profile_provided = False
if len(config.profiles) > 0:
Expand Down Expand Up @@ -174,7 +174,7 @@ def _get_profile(

# 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 614c09d

Please sign in to comment.