Skip to content

Commit

Permalink
refactor: rename global_filter to global_settings
Browse files Browse the repository at this point in the history
  • Loading branch information
guilatrova committed Sep 12, 2021
1 parent 2275d35 commit b873476
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/tryceratops/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ def entrypoint(
):
pyproj_config = load_config(dir)
if pyproj_config:
global_filter = GlobalSettings.create_from_config(pyproj_config)
global_filter.overwrite_from_cli(experimental, ignore, exclude, autofix)
global_settings = GlobalSettings.create_from_config(pyproj_config)
global_settings.overwrite_from_cli(experimental, ignore, exclude, autofix)
else:
global_filter = GlobalSettings(experimental, ignore, exclude, autofix)
global_settings = GlobalSettings(experimental, ignore, exclude, autofix)

if verbose:
logger = logging.getLogger("tryceratops")
logger.setLevel(logging.DEBUG)

parsed_files = list(discovery.parse_python_files(dir))
runner.analyze(parsed_files, global_filter)
runner.analyze(parsed_files, global_settings)

interface.present_and_exit()

Expand Down
4 changes: 2 additions & 2 deletions src/tryceratops/analyzers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
}


def get_analyzer_chain(global_filter: GlobalSettings) -> Set[BaseAnalyzer]:
def get_analyzer_chain(global_settings: GlobalSettings) -> Set[BaseAnalyzer]:
analyzers = {
analyzercls()
for analyzercls in ANALYZER_CLASSES
if global_filter.should_run_processor(analyzercls)
if global_settings.should_run_processor(analyzercls)
}
return analyzers
4 changes: 2 additions & 2 deletions src/tryceratops/fixers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
}


def get_fixers_chain(global_filter: GlobalSettings) -> Set[BaseFixer]:
def get_fixers_chain(global_settings: GlobalSettings) -> Set[BaseFixer]:
fixers = {
fixercls() for fixercls in FIXER_CLASSES if global_filter.should_run_processor(fixercls)
fixercls() for fixercls in FIXER_CLASSES if global_settings.should_run_processor(fixercls)
}
return fixers
6 changes: 3 additions & 3 deletions src/tryceratops/flake_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def __init__(

ignore_lines = list(parse_ignore_tokens(file_tokens))
self._file_filter = FileFilter(ignore_lines)
self._global_filter = self._create_global_filter(filename)
self._global_settings = self._create_global_settings(filename)

def _create_global_filter(self, filename: str) -> GlobalSettings:
def _create_global_settings(self, filename: str) -> GlobalSettings:
pyproj_config = load_config([filename])
if pyproj_config:
filter = GlobalSettings.create_from_config(pyproj_config)
Expand All @@ -52,7 +52,7 @@ def _execute_analyzer(self) -> List[Violation]:
self._file_filter,
)
]
return self._runner.analyze(tryceratops_input, self._global_filter)
return self._runner.analyze(tryceratops_input, self._global_settings)

def run(self) -> Generator[FLAKE8_VIOLATION_TYPE, None, None]:
violations = self._execute_analyzer()
Expand Down
10 changes: 5 additions & 5 deletions src/tryceratops/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ def _run_fixers(self, fixers: Set[BaseFixer]):
else:
self.fixed_violations += fixer.fixes_made

def analyze(self, trees: ParsedFilesType, global_filter: GlobalSettings) -> List[Violation]:
analyzers = get_analyzer_chain(global_filter)
fixers = get_fixers_chain(global_filter)
def analyze(self, trees: ParsedFilesType, global_settings: GlobalSettings) -> List[Violation]:
analyzers = get_analyzer_chain(global_settings)
fixers = get_fixers_chain(global_settings)
self._clear()
self.analyzed_files = len(trees)

for filename, tree, filefilter in trees:
if global_filter.should_skip_file(filename):
if global_settings.should_skip_file(filename):
self.analyzed_files -= 1
self.excluded_files += 1
continue

self._run_analyzers(analyzers, filename, filefilter, tree)

if global_filter.autofix and self.any_violation:
if global_settings.autofix and self.any_violation:
self._run_fixers(fixers)

return self.violations
Expand Down

0 comments on commit b873476

Please sign in to comment.