Skip to content

New semantic analyzer: possible cyclic definition for ignored recursive type #7069

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

Closed
antonagestam opened this issue Jun 26, 2019 · 5 comments

Comments

@antonagestam
Copy link
Contributor

We are using a type definition that looks like this for returning dicts that should be JSON serializable:

Serializable = Dict[  # type: ignore
    str, Union[
        'Serializable', List['Serializable'], Tuple['Serializable'], float, str,
        datetime.datetime, datetime.time]]

Without the new semantic analyzer this passes and gives errors for dicts with incorrectly typed values one level down.

However with the new semantic analyzer this breaks on both the definition of the type:

error: Cannot resolve name "Serializable" (possible cyclic definition)

And on imports of the type in other modules:

error: Module '...serialize' has no attribute 'Serializable'

This is when using stable mypy from PyPI (mypy 0.711) with mypy --new-semantic-analyzer . and the following settings:

[mypy]
ignore_missing_imports = True
strict_optional = True
no_implicit_optional = True
check_untyped_defs = True
disallow_incomplete_defs = True
plugins = sqlmypy

I am aware that recursive types are not yet supported, but I still thought it was worth reporting this as it's a feature regression.

@ilevkivskyi
Copy link
Member

This is a known limitation. In the process of migrating to new analyzer we dropped some partial support of recursive types. It will be brought back in near future (in the form of general recursive types support).

@earonesty
Copy link

Can't wait! We like to use this for our serializable structures as well.

@ulidtko
Copy link

ulidtko commented Mar 31, 2020

This is a known limitation.

Known to whom?

Can the mypy FAQ document this?

@ikelos
Copy link

ikelos commented Oct 12, 2020

Is there a tracker so that people can find out when this will be resolved? Having the ticket closed suggests that there's no additional work to be done?

@antonagestam
Copy link
Contributor Author

@ikelos There is already an issue for recursive types that isn't very hard to find: #731

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

No branches or pull requests

5 participants