fix: restore unreachable no-default-class error in load_plugin - #2011
Open
manunicholasjacob wants to merge 1 commit into
Open
fix: restore unreachable no-default-class error in load_plugin#2011manunicholasjacob wants to merge 1 commit into
manunicholasjacob wants to merge 1 commit into
Conversation
load_plugin read generator_mod.DEFAULT_CLASS directly, so a module without that attribute raised AttributeError before the else branch could run. That made the 'no default class; pass module.ClassName to target_type' ValueError unreachable, and callers passing break_on_fail=False got an exception instead of False. Use a defaulted lookup so the intended error path is reachable. Signed-off-by: manunicholasjacob <manunicholasjacob@gmail.com>
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.
What this changes
load_plugin()readsgenerator_mod.DEFAULT_CLASSdirectly when a plugin isspecified as
category.module. If the module does not define that attribute,the attribute access raises
AttributeError, so theelsebranch below itcannot be reached:
Two consequences:
ValueErrorabove, and its guidance to passmodule.ClassName, neversurfaces. Users see an
AttributeErrorinstead.tryonly catchesValueError, so callers passingbreak_on_fail=Falsereceive an exception rather thanFalse.This switches the read to a defaulted lookup so the existing error path works
as written. No behaviour changes for modules that do define
DEFAULT_CLASS.Reproduction
Also reachable from the CLI, e.g.
--target_type base.Testing
Adds
test_load_plugin_module_without_default_classtotests/plugins/test_plugin_load.py, covering both thebreak_on_fail=Falsereturn value and the
ValueErrormessage. The test fails onmainand passeswith this change. Full
tests/plugins/suite passes.