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

Symlinks are not followed #227

Closed sshane closed 2 months ago

sshane commented 2 months ago

I haven't looked into why yet with this library, but symlinks do not seem to be followed properly:

# selfdrive/car/toyota/values.py
from openpilot.system import ...  # this should be banned
openpilot/  # main project directory
├── openpilot/
│   ├── __init__.py
│   ├── selfdrive/
│   │   ├── ... (other files)
│   ├── system/
│   │   ├── ... (other files)
│   ├── selfdrive/ (symlink to ../selfdrive)
│   │   ├── __init__.py
│   │   ├── car/
│   │   │   ├── __init__.py
│   │   │   └── ... (other files)
│   ├── system/ (symlink to ../system)
│       ├── __init__.py
│       └── ... (other files)
├── .importlinter
├── .pre-commit-config.yaml

But the error message I get is:

Missing layer 'openpilot.system': module openpilot.system does not exist.

If I copy the system/ and selfdrive/ folders from the root into the openpilot/openpilot folder such that they aren't symlinks anymore, then it can find it.

# .importlinter
[importlinter]
root_packages=
    openpilot

[importlinter:contract:1]
name = Banned openpilot.system
type = layers
layers=
    openpilot.system
    openpilot.selfdrive.car
sshane commented 2 months ago

Seems to be fixed with https://github.com/seddonym/grimp/pull/152. You can close if you like since it's not this module's problem