Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for stub modules semantics #72

Closed

Conversation

tristanlatr
Copy link
Contributor

@tristanlatr tristanlatr commented Aug 8, 2023

Fixes #55

I implemented some flexibility around the module name resolving and detect whether the module is a stub or a package. So isolating this new feature into a new class doesn’t really make sens. Because we’ll loose some auto detection feature that all users of beniget should enjoy having builtin.

Let me know what you think of this implementation.

I'll add more comments...

beniget/beniget.py Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
beniget/beniget.py Outdated Show resolved Hide resolved
beniget/beniget.py Outdated Show resolved Hide resolved
@tristanlatr tristanlatr marked this pull request as ready for review September 21, 2023 20:31
else:
return self.orgmodule

_alias_needs_lineno = platform.python_implementation().lower() == 'cpython' and sys.version_info < (3,10)
Copy link
Owner

Choose a reason for hiding this comment

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

I'd rather do _alias_needs_lineno = 'lineno' in ast.alias._attributes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hum, i don’t think it will work. Since the field exists but is set to None (I believe)

beniget/beniget.py Outdated Show resolved Hide resolved
beniget/beniget.py Outdated Show resolved Hide resolved
beniget/beniget.py Show resolved Hide resolved
@@ -290,14 +468,61 @@ class DefUseChains(ast.NodeVisitor):
One instance of DefUseChains is only suitable to analyse one AST Module in it's lifecycle.
"""

def __init__(self, filename=None):
def __init__(self,
Copy link
Owner

Choose a reason for hiding this comment

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

I'm stopping my review here, I think we discussed you should try to subclass beniget instead of adding a conditional path in it. Did you change your mind?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the reason is described in the PR text. But let’s chat about it

@tristanlatr
Copy link
Contributor Author

Can you continue your review of these changes?

@tristanlatr
Copy link
Contributor Author

Hello @serge-sans-paille, and happy new year.
Any further opinion about this change?
Thanks a lot

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.

Using beniget to parse stubs produce errors
2 participants