Skip to content

Commit

Permalink
Use Grimp.find_illegal_dependencies_for_layers
Browse files Browse the repository at this point in the history
  • Loading branch information
seddonym committed Jul 6, 2023
1 parent dd61468 commit bb0b099
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 541 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ latest
* Recursive wildcard support for ignored imports.
* Drop support for Python 3.7.
* Use grimp.ImportGraph instead of importlinter.domain.ports.graph.ImportGraph.
* Use grimp's find_illegal_dependencies_for_layers method in layers contracts.

1.9.0 (2023-05-13)
------------------
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ authors = [
requires-python = ">=3.8"
dependencies = [
"click>=6",
# Temporarily use master branch of Grimp.
"grimp@git+https://github.com/seddonym/grimp",
"grimp>=2.5",
"tomli>=1.2.1; python_version < '3.11'",
"typing-extensions>=3.10.0.0",
]
Expand Down
26 changes: 26 additions & 0 deletions src/importlinter/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
from logging import config as logging_config
from typing import Optional, Tuple, Type, Union

import click
Expand Down Expand Up @@ -91,6 +92,8 @@ def lint_imports(
# Add current directory to the path, as this doesn't happen automatically.
sys.path.insert(0, os.getcwd())

_configure_logging(verbose)

combined_cache_dir = _combine_caching_arguments(cache_dir, no_cache)

passed = use_cases.lint_imports(
Expand All @@ -116,3 +119,26 @@ def _combine_caching_arguments(
if cache_dir is None:
return NotSupplied
return cache_dir


def _configure_logging(verbose: bool) -> None:
logger_names = ("importlinter", "grimp")
logging_config.dictConfig(
{
"version": 1,
"handlers": {
"console": {
"class": "logging.StreamHandler",
"level": "INFO" if verbose else "WARNING",
"stream": "ext://sys.stdout",
},
},
"loggers": {
logger_name: {
"level": "INFO",
"handlers": ["console"],
}
for logger_name in logger_names
},
}
)

0 comments on commit bb0b099

Please sign in to comment.