Skip to content

Commit

Permalink
Updated outstanding refernces to 'logger' when referring to hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
surge119 committed Jul 24, 2024
1 parent 8bb6ecb commit a25e286
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions src/fixit/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def fixit_bytes(
*,
config: Config,
autofix: bool = False,
logger_hook: Optional[MetricsHook] = None,
metrics_hook: Optional[MetricsHook] = None,
) -> Generator[Result, bool, Optional[FileContent]]:
"""
Lint raw bytes content representing a single path, using the given configuration.
Expand Down Expand Up @@ -129,7 +129,7 @@ def fixit_bytes(
pending_fixes: List[LintViolation] = []

clean = True
for violation in runner.collect_violations(rules, config, logger_hook):
for violation in runner.collect_violations(rules, config, metrics_hook):
clean = False
fix = yield Result(path, violation)
if fix or autofix:
Expand All @@ -155,7 +155,7 @@ def fixit_stdin(
*,
autofix: bool = False,
options: Optional[Options] = None,
logger_hook: Optional[MetricsHook] = None,
metrics_hook: Optional[MetricsHook] = None,
) -> Generator[Result, bool, None]:
"""
Wrapper around :func:`fixit_bytes` for formatting content from STDIN.
Expand All @@ -173,7 +173,7 @@ def fixit_stdin(
config = generate_config(path, options=options)

updated = yield from fixit_bytes(
path, content, config=config, autofix=autofix, logger_hook=logger_hook
path, content, config=config, autofix=autofix, metrics_hook=metrics_hook
)
if autofix:
sys.stdout.buffer.write(updated or content)
Expand All @@ -188,7 +188,7 @@ def fixit_file(
*,
autofix: bool = False,
options: Optional[Options] = None,
logger_hook: Optional[MetricsHook] = None,
metrics_hook: Optional[MetricsHook] = None,
) -> Generator[Result, bool, None]:
"""
Lint a single file on disk, detecting and generating appropriate configuration.
Expand All @@ -208,7 +208,7 @@ def fixit_file(
config = generate_config(path, options=options)

updated = yield from fixit_bytes(
path, content, config=config, autofix=autofix, logger_hook=logger_hook
path, content, config=config, autofix=autofix, metrics_hook=metrics_hook
)
if updated and updated != content:
LOG.info(f"{path}: writing changes to file")
Expand All @@ -224,14 +224,14 @@ def _fixit_file_wrapper(
*,
autofix: bool = False,
options: Optional[Options] = None,
logger_hook: Optional[MetricsHook] = None,
metrics_hook: Optional[MetricsHook] = None,
) -> List[Result]:
"""
Wrapper because generators can't be pickled or used directly via multiprocessing
TODO: replace this with some sort of queue or whatever
"""
return list(
fixit_file(path, autofix=autofix, options=options, logger_hook=logger_hook)
fixit_file(path, autofix=autofix, options=options, metrics_hook=metrics_hook)
)


Expand All @@ -241,7 +241,7 @@ def fixit_paths(
autofix: bool = False,
options: Optional[Options] = None,
parallel: bool = True,
logger_hook: Optional[MetricsHook] = None,
metrics_hook: Optional[MetricsHook] = None,
) -> Generator[Result, bool, None]:
"""
Lint multiple files or directories, recursively expanding each path.
Expand Down Expand Up @@ -292,19 +292,19 @@ def fixit_paths(

if is_stdin:
yield from fixit_stdin(
stdin_path, autofix=autofix, options=options, logger_hook=logger_hook
stdin_path, autofix=autofix, options=options, metrics_hook=metrics_hook
)
elif len(expanded_paths) == 1 or not parallel:
for path in expanded_paths:
yield from fixit_file(
path, autofix=autofix, options=options, logger_hook=logger_hook
path, autofix=autofix, options=options, metrics_hook=metrics_hook
)
else:
fn = partial(
_fixit_file_wrapper,
autofix=autofix,
options=options,
logger_hook=logger_hook,
metrics_hook=metrics_hook,
)
for _, results in trailrunner.run_iter(expanded_paths, fn):
yield from results
4 changes: 2 additions & 2 deletions src/fixit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def lint(
autofixes = 0
config = generate_config(options=options)
for result in fixit_paths(
paths, options=options, logger_hook=print if options.print_metrics else None
paths, options=options, metrics_hook=print if options.print_metrics else None
):
visited.add(result.path)
if print_result(
Expand Down Expand Up @@ -210,7 +210,7 @@ def fix(
autofix=autofix,
options=options,
parallel=False,
logger_hook=print if options.print_metrics else None,
metrics_hook=print if options.print_metrics else None,
)
)
config = generate_config(options=options)
Expand Down

0 comments on commit a25e286

Please sign in to comment.