Skip to content

FA100 doesn't catch using modern annotation syntax when target version is 3.9 #4553

@akx

Description

@akx

As I'm reading it, FA100 should add a from __future__ import annotations import when a file already uses modern annotation syntax and the configuration targets Python 3.9, but it doesn't:

Refs AUTOMATIC1111/stable-diffusion-webui#10580

$ cat a.py
def foo(x: str | None):
	pass
$ ruff --version
ruff 0.0.269
$ ruff --target-version=py39 --select=FA100 --isolated a.py
$ ~/.pyenv/versions/3.9.16/bin/python3.9 a.py
Traceback (most recent call last):
  File "a.py", line 1, in <module>
    def foo(x: str | None):
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for support or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions