Remove star imports#4983
Draft
jasonb5 wants to merge 2 commits into
Draft
Conversation
Contributor
|
You can preview documentation at https://esmci.github.io/cime/branch/fix/refactor-star-imports/html/index.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Removes wildcard (
from ... import *) imports across the CIME Python codebaseand applies consistent PEP 8 import ordering to every file touched. Wildcard
imports hide a module's true dependencies, defeat static analysis, and let
unrelated symbols collide across modules.
Star imports removed (106 files)
from CIME.XML.standard_module_setup import *withexplicit imports
from CIME.test_status import *with explicit importsfrom CIME.Tools.standard_script_setup import *inCIME/scripts/*isintentionally left in place (that module is the script bootstrap shim).
Import reordering (114 additional files)
Where imports were already explicit, the order was normalized to PEP 8 style:
import a, b, ccollapsed to one module per linefrom X import (a, b, c)alphabetizedBackward compatibility preserved
CIME/XML/standard_module_setup.py— marked DEPRECATED in the docstring;explicit imports tagged
# noqa: F401so external code that still doesfrom CIME.XML.standard_module_setup import *(E3SM, CESM, NorESMcime_config/) continues to receive the same names.CIME/Tools/standard_script_setup.py— same treatment; also adds explicitre-exports of
argparseandlogging.Totals
pyproject.toml,setup.cfg, or.isort.cfgmodified)
Test status
Running
pytest CIME/tests/ -k test_unit(withCIME_MACHINE=linux-generic,E3SM
cime_config/) yields 11 failed, 378 passed, 13 skipped. The same11 failures reproduce identically on
masterand on the base branchfeat/refactor-core-foundation(PR #4982). They are pre-existing issuesunrelated to this PR — caused by E3SM machine-config / baseline mismatches
in the local test environment, not by import changes. Confirmed by running
the same suite on all three branches from clean worktrees.
Depends on: #4982
Checklist