Skip to content

remove from . import * in unittests#58

Merged
ilaflott merged 5 commits intomainfrom
poke-test
Feb 4, 2026
Merged

remove from . import * in unittests#58
ilaflott merged 5 commits intomainfrom
poke-test

Conversation

@ilaflott
Copy link
Member

@ilaflott ilaflott commented Jan 27, 2026

Describe your changes

This PR refactors the test suite to replace wildcard imports (from . import *) with explicit imports, improving code clarity and pylint compliance.

Key Changes:

  1. Removed wildcard imports from epmt.test: All test modules now use explicit imports instead of from . import *

  2. test/__init__.py now empty: Removed the 45-line monolithic import block

  3. Updated CI workflow: Moved pylint checks to end of workflow and pylint threshold increased from 6.5 to 7.0

  4. Bug fix: Corrected typo in epmt_query.py (unavailable__metricsunavailable_metrics)

Benefits:

  • Dependencies are now explicit and visible
  • Better IDE/tooling support
  • Test functioning is the same as before

Issue ticket number, link (if applicable)

No associated issue

Checklist

  • the code runs
  • the code is readable
  • the code is commented
  • there are no additional failures in GUARDED pipeline tasks (pending CI)
  • a new test was written (if applicable) (N/A)
  • new instructions/doc was written (if applicable) (N/A)
  • I ran pylint and attempted to implement some of its feedback

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.80%. Comparing base (7166a58) to head (dc7b65e).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #58      +/-   ##
==========================================
- Coverage   64.86%   64.80%   -0.07%     
==========================================
  Files          28       28              
  Lines        6469     6469              
==========================================
- Hits         4196     4192       -4     
- Misses       2273     2277       +4     
Flag Coverage Δ
unittests 64.80% <ø> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…systematically remove the commented out imports since we are feelinmg better about this idea
@ilaflott ilaflott marked this pull request as ready for review January 27, 2026 21:16
@ilaflott ilaflott requested a review from Copilot January 27, 2026 21:17
@ilaflott ilaflott added enhancement New feature or request cleanup labels Jan 27, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the test suite to eliminate wildcard imports (from . import *) and replace them with explicit imports, improving code maintainability and pylint compliance. The changes also include a bug fix and CI workflow optimization.

Changes:

  • Replaced wildcard imports with explicit imports across 13 test files
  • Emptied test/__init__.py (removed 45-line import block)
  • Fixed typo in epmt_query.py (unavailable__metricsunavailable_metrics)
  • Optimized CI workflow by moving pylint checks after tests and increasing threshold from 6.5 to 7.0

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test/init.py Removed all imports, now empty file
test_submit.py Added explicit imports for unittest, glob, datetime, settings, query, models, and orm functions
test_stat.py Removed commented wildcard import and shebang
test_shell.py Added explicit unittest import, removed wildcard import
test_settings.py Added explicit imports, reordered imports for clarity
test_run.py Added explicit imports for os, environ, shutil, and epmt modules
test_query.py Added comprehensive explicit imports for all dependencies
test_outliers.py Added explicit imports including json, glob, unittest, and epmt modules
test_lib.py Added explicit imports using multi-line import statement
test_explore.py Added explicit imports for epmt modules and utilities
test_db_schema.py Added explicit imports for unittest and orm modules
test_db_migration.py Added explicit imports for settings and orm modules
test_cmds.py Added comprehensive explicit imports for all test dependencies
test_anysh.py Added explicit imports and simplified comments
epmt_query.py Fixed typo in variable name (double to single underscore)
build_and_test_epmt.yml Moved pylint checks to end of workflow, increased threshold to 7.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.



# the import below is crucial to get a sane test environment
from epmt.orm.sqlalchemy.general import orm_get, orm_to_dict
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function orm_to_dict is imported here but used inconsistently in the file. It's called as eq.orm_to_dict on line 40 but as orm_to_dict on line 642. Since it's imported directly, both usages should be orm_to_dict (without the eq. prefix) for consistency.

Copilot uses AI. Check for mistakes.
(path.getsize(install_root + '/settings.py') > 0))
try:
import epmt.epmt_settings as settings
assert settings is not None
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion is unnecessary. If the import statement on line 32 succeeds, settings will be defined and not None. If the import fails, the except block on line 34 will catch it. This assertion adds no value and should be removed.

Suggested change
assert settings is not None

Copilot uses AI. Check for mistakes.
from epmt.epmtlib import timing, capture, epmt_logging_init, get_install_root, str_dict
import epmt.epmt_query as eq

install_root=get_install_root()
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing spaces around the assignment operator. Should be install_root = get_install_root() to comply with PEP 8 style guidelines, as seen in other test files like test_explore.py (line 12), test_submit.py (line 15), and test_run.py (line 15).

Suggested change
install_root=get_install_root()
install_root = get_install_root()

Copilot uses AI. Check for mistakes.
from epmt.epmt_cmds import epmt_submit
from epmt.orm.sqlalchemy.models import Job

install_root=get_install_root()
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing spaces around the assignment operator. Should be install_root = get_install_root() to comply with PEP 8 style guidelines, as seen in other test files like test_explore.py (line 12), test_submit.py (line 15), and test_run.py (line 15).

Suggested change
install_root=get_install_root()
install_root = get_install_root()

Copilot uses AI. Check for mistakes.

# from epmt.orm.sqlalchemy.models import UnprocessedJob
# from os import path
install_root=get_install_root()
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing spaces around the assignment operator. Should be install_root = get_install_root() to comply with PEP 8 style guidelines, as seen in other test files like test_explore.py (line 12), test_submit.py (line 15), and test_run.py (line 15).

Suggested change
install_root=get_install_root()
install_root = get_install_root()

Copilot uses AI. Check for mistakes.
@@ -1,11 +1,13 @@
#!/usr/bin/env python
import os
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module 'os' is imported with both 'import' and 'import from'.

Copilot uses AI. Check for mistakes.

from . import *
# import os
import os
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module 'os' is imported with both 'import' and 'import from'.

Copilot uses AI. Check for mistakes.
@ilaflott ilaflott merged commit 2abec3d into main Feb 4, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant