Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix verdi devel check-undesired-imports when tui extra is installed #6693

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,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_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 @@
'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
Loading