Skip to content

Add type hints#17

Merged
henri-hulski merged 1 commit into
morepath:masterfrom
seantis:feat/typing
Jun 5, 2026
Merged

Add type hints#17
henri-hulski merged 1 commit into
morepath:masterfrom
seantis:feat/typing

Conversation

@Daverball
Copy link
Copy Markdown
Contributor

@Daverball Daverball commented Jun 5, 2026

These type hints I had to create from scratch, but were by far the most straightforward.

It is however worth noting that by adding the type hints, it came to light, that scan currently does not handle MetaPathFinder importers, so we maybe should open an issue for that and try to add support for them in the future.

I also noticed that there's some strange logic when it comes to packages vs. plain modules. Since walk_packages always imports packages, we technically don't need to import them again in scan (even though going through __import__ guarantees that the actual import only happens once). The other thing that's strange about that is that we use a import_module helper function in scan to skip loading some modules, but we don't do that in walk_packages, so the check only really works on plain modules, not packages. This might also be worth investigating and opening a ticket for.

I also decided to get rid of the workarounds for old finders that only have a find_module, but no find_spec method, since those have been deprecated since 3.4 and fully unsupported since 3.9, so those finders would not work with 3.10 anyways and importing the module would fail.

/cc @henri-hulski

Copy link
Copy Markdown
Member

@henri-hulski henri-hulski left a comment

Choose a reason for hiding this comment

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

If you want to modernize importscan,feel free to go. I wasn't digging into it to much and I don't remember that there was any work done beside modernizing the workflow.
Other than Morepath or Reg.
So I think it can use some review.

@henri-hulski henri-hulski merged commit d3d07c0 into morepath:master Jun 5, 2026
7 checks passed
@Daverball Daverball deleted the feat/typing branch June 5, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants