seddonym / import-linter

Import Linter allows you to define and enforce rules for the internal and external imports within your Python project.
https://import-linter.readthedocs.io/
BSD 2-Clause "Simplified" License
664 stars 45 forks source link

Enhance: allow extra empty line & spaces between the module names in the `ignore_imports` #194

Closed piglei closed 11 months ago

piglei commented 11 months ago

Enhance: allow extra empty line & spaces between the module names in the ignore_imports

The config blow contains some extra spaces and blank lines in the ignored_imports section:

[importlinter]
root_packages =
    foo_proj

[importlinter:contract:layers-main]
name=the main layers
type=layers
layers =
    foo_proj.client
    foo_proj.lib
ignore_imports =
    foo_proj.lib.a     ->   foo_proj.client

    # Some comment
    foo_proj.lib.b -> foo_proj.client

In the current version, the linter throws a vague exception. this PR changes the parser to make it work normally.

piglei commented 11 months ago

I've updated the code as discussed.