Repository navigation
feat(application): route and class discovery accept a single module - #341
Merged
Merged
Conversation
find_package_routes and get_all_classes took only a package: import_recursively read __path__, which a module lacks. A module name now yields that module, so a flat project can scan myapp.api without moving it into a subpackage. A class counts as defined in the scanned package or module only when its module is that name or below it. The plain prefix check also matched a sibling such as myapp.api_utils. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
andrey-berenda
approved these changes
Oct 13, 2026
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.
winter.web.find_package_routesandget_all_classesaccepted only a package.import_recursivelyread__path__, so a module name failed withAttributeError. A project that wants its API inmyapp/api.pyhad to turn it into a subpackage just for discovery.Now a module name yields that module. Packages behave as before.
The ownership check is tightened in the same function. A class counted as found when its
__module__merely started with the scanned name, so scanningmyapp.apiwould also pick classes imported from a siblingmyapp.api_utils. Now the module must be the scanned name or below it. For packages this only removes such false positives.The change also applies to the event and domain event autodiscovery, which use
get_all_classes.Motivation: WinterFramework/winter-getting-started#7 wants a flat
simple_api/api.pyandsimple_api/openapi.py.Tests: discovery of a module, of a package, and the sibling-prefix case; both module tests fail without the change. Coverage is complete except Redis, which needs Docker locally.
🤖 Generated with Claude Code