这是indexloc提供的服务,不要输入任何密码
Skip to content

Reciprocal to rules like UP007 and UP045 for preserving native type annotation syntax #19402

@smroels

Description

@smroels

Summary

In a py3.9 context with from __future__ import annotations, we are using keep-runtime-typing = true
to avoid application of rules like UP007 and UP045 that suggest use of X | None or X | Y syntax instead of Optional[X] and Union{X|Y].
This is to avoid issues with Pydantic while nevertheless permitting us to address forward referencing issues.

It would be valuable to actually have reciprocal rules that flag the use of non-native py3.9 type annotation syntax with from __future__ import annotations. That is, not only would X | None not be suggested, it would get flagged as an issue if observed. This would presumably be non-default behavior, but something that could be opted into.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionAwaiting a decision from a maintainerruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions