Conversation
Author
|
@HAOCHENYE could you take a look when you have some time? The two failing checks ( |
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.
importlib.util.find_specimports the leading component of a dotted module name to resolve it, and raisesModuleNotFoundErrorinstead of returningNonewhen that component isn't importable.is_installed,get_installed_path, andpackage2moduleinmmengine/utils/package_utils.pycallfind_specdirectly on the package name. Fine for a single-level name —find_spec('nonexistentpackage12345')returnsNone. Not fine for a dotted name whose leading segment isn't installed, e.g. a namespace package likezope.interface:is_installedshould returnFalsehere — that's what thedistribution()fallback exists for.get_installed_pathshould raise thePackageNotFoundErrorit documents, not aModuleNotFoundErrornaming a truncated module that was never the argument.Reachable through
Config._get_cfg_path(mmengine/config/config.py:1263), which callsis_installed(package)to give a friendly error when an external config's scope package isn't installed.Reproduced on current
main(f8a8b1b) with Python 3.12.3, command above.Fix: wrap the
find_speccalls inis_installedandpackage2modulewithtry/except ModuleNotFoundError, same handling as aNonereturn. Added regression tests totests/test_utils/test_package_utils.pycovering both functions with a dotted name whose leading component doesn't exist.pytest tests/test_utils/test_package_utils.pypasses, 2/2.flake8andisortare clean on the diff.