Skip to content

Cycle detected in import chain #746

@falan

Description

@falan

Describe the bug
Pyright report cycle detected in import chain when using the method described in the link.
https://mypy.readthedocs.io/en/stable/common_issues.html#import-cycles

To Reproduce
File foo.py:

from typing import List, TYPE_CHECKING

if TYPE_CHECKING:
    import bar

def listify(arg: 'bar.BarClass') -> 'List[bar.BarClass]':
    return [arg]

File bar.py:

from typing import List
from foo import listify

class BarClass:
    def listifyme(self) -> 'List[BarClass]':
        return listify(self)

Expected behavior
No errors.

VS Code extension or command-line
VS Code extension 1.1.44
Python 3.7.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    as designedNot a bug, working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions