Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Mypy symbol resolve #537

Merged
merged 33 commits into from
Aug 15, 2024
Merged

Mypy symbol resolve #537

merged 33 commits into from
Aug 15, 2024

Conversation

mgtm98
Copy link
Collaborator

@mgtm98 mgtm98 commented Jul 27, 2024

Description

@mgtm98 mgtm98 requested review from kugesan1105 and marsninja August 4, 2024 22:43
@marsninja
Copy link
Contributor

Hey @mgtm98 @kugesan1105 and @ThakeeNathees , I've played with this pr and its a strong approach though I see there's future work, if we can finalize and clean this up a bit i'd be happy to merge, one thing i'd like to do is not do the monkey patching on static class variables to share information across passes, any info that should be shared across passes should probably be save in the IR itself (ie. the ast). Happy to hop on a call and deep dive this with you guys.

Comment on lines 220 to 233
def process_import(self, node: ast.Module, i: ast.ModulePath) -> None:
"""Process an import."""
imp_node = i.parent_of_type(ast.Import)
if (
imp_node.is_py
and not i.sub_module
and not is_standard_lib_module(i.path_str)
):
mod = self.import_py_module(node=i, mod_path=node.loc.mod_path)
if mod:
i.sub_module = mod
i.add_kids_right([mod], pos_update=False)
if settings.py_raise_deep:
self.run_again = True
Copy link
Contributor

Choose a reason for hiding this comment

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

I've looked into it and i think the approach shoudl be something like this except that when its a paackage/directory you automatically create import nodes for the relevant modules based on the python raise list

Basically, in teh import_py_module function you only import the module path if its in the list. You should naturally end up keeping the right parent relationship.

@marsninja marsninja merged commit 3aa9975 into main Aug 15, 2024
3 of 4 checks passed
@marsninja marsninja deleted the mypy_symbol_resolve branch August 15, 2024 16:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants