Skip to content

pytype should not assume that "from . import X" is always a module import #882

@rchen152

Description

@rchen152

Consider the following type stubs:

# foo/__init__.pyi
class Foo: ...
# foo/bar.pyi
from . import Foo
class Bar(Foo): ...

When parsing foo/bar.pyi, pytype fails with:

ParseError: Unexpected class base: Module(name='Foo', module_name='foo.Foo')

pytype erroneously assumes that Foo is a submodule. A workaround is to replace from . import Foo with from foo import Foo.

Context: python/typeshed#5192

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions