We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug Assertion error while loading simple module with an import inside a class.
To Reproduce Steps to reproduce the behavior: Try to parse the following module with load_python_modules():
load_python_modules()
class session: from twisted.conch.interfaces import ISession
Expected behavior A new module should be returned, with an Indirection inside a class.
Actual bahaviour
I get the following error
self = <docspec_python.parser.Parser object at 0x106763f10> parent = Module(name='test', members=[]) node = Node(classdef, [Leaf(1, 'class'), Leaf(1, 'session'), Leaf(11, ':'), Node(suite, [Leaf(4, '\n'), Leaf(5, ' '), Node...h'), Leaf(23, '.'), Leaf(1, 'interfaces')]), Leaf(1, 'import'), Leaf(1, 'ISession')]), Leaf(4, '\n')]), Leaf(6, '')])]) decorations = None def parse_classdef(self, parent, node, decorations): name = node.children[1].value bases = [] metaclass = None # An arglist is available if there are at least two parameters. # Otherwise we have to deal with parsing a raw sequence of nodes. classargs = find(lambda x: x.type == syms.arglist, node.children) if classargs: metaclass, bases = self.parse_classdef_arglist(classargs) else: metaclass, bases = self.parse_classdef_rawargs(node) suite = find(lambda x: x.type == syms.suite, node.children) docstring = self.get_docstring_from_first_node(suite) if suite else None class_ = Class( name=name, location=self.location_from(node), docstring=docstring, metaclass=metaclass, bases=bases, decorations=decorations, members=[]) for child in suite.children if suite else []: if isinstance(child, Node): member = self.parse_declaration(class_, child) > assert not isinstance(member, (list, Module)), member E AssertionError: [Indirection(name='ISession', target='twisted.conch.interfaces.ISession')]
It's really the indirection inside the class the issue, I've tried with the following, and it works as expected.
from twisted.conch.interfaces import ISession class session: ISession=ISession
The text was updated successfully, but these errors were encountered:
Thanks for reporting @tristanlatr! 🤦 Not sure why I thought asserting here that people don't do imports in classes is a good idea.
Sorry, something went wrong.
fix(docspec-python): support imports on the class-level
11593e7
fixes #34
fix(docspec-python): support imports on the class-level (#35)
8d984dd
Fixed in 1.1.1
Thanks!
NiklasRosenstein
Successfully merging a pull request may close this issue.
Describe the bug
Assertion error while loading simple module with an import inside a class.
To Reproduce
Steps to reproduce the behavior:
Try to parse the following module with
load_python_modules()
:Expected behavior
A new module should be returned, with an Indirection inside a class.
Actual bahaviour
I get the following error
It's really the indirection inside the class the issue, I've tried with the following, and it works as expected.
The text was updated successfully, but these errors were encountered: