Skip to content

Commit f09409a

Browse files
refactor: handle gracefully lib/pypi not being there
1 parent 1077e36 commit f09409a

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

natrix/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ def get_project_root():
7676

7777
def read_pyproject_config():
7878
"""Read configurations from pyproject.toml if it exists"""
79-
# Default path includes lib/pypi which is the default dependency folder for moccasin
8079
config = {
8180
"files": [],
8281
"disabled_rules": set(),
8382
"rule_configs": {},
84-
"path": ["lib/pypi"],
83+
"path": [],
8584
}
8685

8786
try:

natrix/ast_tools.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,35 @@ def _obtain_sys_path():
5555
return valid_paths
5656

5757

58+
def _obtain_default_paths():
59+
"""
60+
Obtain default paths for Vyper imports.
61+
Only returns paths that actually exist on the system.
62+
"""
63+
# List of default paths to check
64+
default_paths = [
65+
"lib/pypi", # Default dependency folder for moccasin
66+
# Add more paths here in the future
67+
]
68+
69+
# Return only existing paths
70+
existing_paths = []
71+
for path in default_paths:
72+
if os.path.exists(path) and os.path.isdir(path):
73+
existing_paths.append(path)
74+
75+
return existing_paths
76+
77+
5878
def vyper_compile(filename, formatting, extra_paths=None):
5979
_check_vyper_version()
6080

6181
# For each path add a '-p /the/path' flag to the compiler
6282
paths = [item for p in _obtain_sys_path() for item in ["-p", p]]
83+
84+
# Add default paths (like lib/pypi for moccasin)
85+
for path in _obtain_default_paths():
86+
paths.extend(["-p", path])
6387

6488
# Add extra paths if provided
6589
if extra_paths:

0 commit comments

Comments
 (0)