Skip to content

Commit

Permalink
Fix verdi devel check-undesired-imports when tui extra is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Jan 9, 2025
1 parent 3f5e2c1 commit 1b1a850
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ jobs:
with:
python-version: '3.12'
from-lock: 'true'
# NOTE: The `verdi devel check-undesired-imports` fails if
# the 'tui' extra is installed.
extras: ''

- name: Run verdi tests
Expand Down
12 changes: 8 additions & 4 deletions src/aiida/cmdline/commands/cmd_devel.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ def devel_check_load_time():
def devel_check_undesired_imports():
"""Check that verdi does not import python modules it shouldn't.
Note: The blacklist was taken from the list of packages in the 'atomic_tools' extra but can be extended.
This is to keep the verdi CLI snappy, especially for tab-completion.
"""
loaded_modules = 0

for modulename in [
'asyncio',
unwanted_modules = [

Check warning on line 68 in src/aiida/cmdline/commands/cmd_devel.py

View check run for this annotation

Codecov / codecov/patch

src/aiida/cmdline/commands/cmd_devel.py#L68

Added line #L68 was not covered by tests
'requests',
'plumpy',
'disk_objectstore',
Expand All @@ -78,7 +77,12 @@ def devel_check_undesired_imports():
'spglib',
'pymysql',
'yaml',
]:
]
# trogon powers the optional TUI and uses asyncio.
# Check for asyncio only when the optional tui extras are not installed.
if 'trogon' not in sys.modules:
unwanted_modules += 'asyncio'
for modulename in unwanted_modules:

Check warning on line 85 in src/aiida/cmdline/commands/cmd_devel.py

View check run for this annotation

Codecov / codecov/patch

src/aiida/cmdline/commands/cmd_devel.py#L83-L85

Added lines #L83 - L85 were not covered by tests
if modulename in sys.modules:
echo.echo_warning(f'Detected loaded module "{modulename}"')
loaded_modules += 1
Expand Down

0 comments on commit 1b1a850

Please sign in to comment.