Skip to content

FA102 is missing collection.abc types #20512

@Andrej730

Description

@Andrej730

Summary

E.g. use of Sequence[int] is not flagged.
See example below (command I've used is ruff check test.py --target-version py38 --select=FA102)

Ruff playground - https://play.ruff.rs/b295c8a4-4295-4a5a-8a2d-e99699814822

from collections.abc import Sequence

# Not reported by Ruff, but results in runtime error:
# TypeError: 'ABCMeta' object is not subscriptable
def test() -> Sequence[int]:
    return [1, 2, 3]


# FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection
def test2() -> list[int]:
    return [1, 2, 3]

Version

ruff 0.13.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    previewRelated to preview mode featuresruleImplementing 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