Skip to content

Got F811 when indirectly importing overload #19632

@rj-xu

Description

@rj-xu

Summary

from std import overload


@overload
def func(a: str, b: int) -> int: ...
@overload
def func(a: int, b: str) -> int: ...
def func(a: int | str, b: int | str) -> int:
    return 0
typing-modules = ["std"]

#6969
In version 0.12.5, F811 Redefinition still occurs, even though typing-modules have already been set up.
This error will appear after v0.3.0.

ruff --version
ruff 0.3.0 (b53118ed0 2024-02-29)
ruff check .\src\temp.py
src\temp.py:1:1: INP001 File `src\temp.py` is part of an implicit namespace package. Add an `__init__.py`.
src\temp.py:8:10: ARG001 Unused function argument: `a`
src\temp.py:8:24: ARG001 Unused function argument: `b`
Found 3 errors.
ruff --version
ruff 0.3.1 (b9264a5a1 2024-03-06)
ruff check .\src\temp.py
src\temp.py:1:1: INP001 File `src\temp.py` is part of an implicit namespace package. Add an `__init__.py`.
src\temp.py:5:10: ARG001 Unused function argument: `a`
src\temp.py:5:18: ARG001 Unused function argument: `b`
src\temp.py:7:5: F811 Redefinition of unused `func` from line 5
src\temp.py:7:10: ARG001 Unused function argument: `a`
src\temp.py:7:18: ARG001 Unused function argument: `b`
src\temp.py:8:5: F811 Redefinition of unused `func` from line 7
src\temp.py:8:10: ARG001 Unused function argument: `a`
src\temp.py:8:24: ARG001 Unused function argument: `b`
Found 9 errors.
ruff --version
ruff 0.12.5 (d13228ab8 2025-07-24)
ruff check .\src\temp.py
src\temp.py:7:5: F811 Redefinition of unused `func` from line 5
  |
5 | def func(a: str, b: int) -> int: ...
6 | @overload
7 | def func(a: int, b: str) -> int: ...
  |     ^^^^ F811
8 | def func(a: int | str, b: int | str) -> int:
9 |     return 0
  |
  = help: Remove definition: `func`

src\temp.py:8:5: F811 Redefinition of unused `func` from line 7
  |
6 | @overload
7 | def func(a: int, b: str) -> int: ...
8 | def func(a: int | str, b: int | str) -> int:
  |     ^^^^ F811
9 |     return 0
  |
  = help: Remove definition: `func`

src\temp.py:8:10: ARG001 Unused function argument: `a`
  |
6 | @overload
7 | def func(a: int, b: str) -> int: ...
8 | def func(a: int | str, b: int | str) -> int:
  |          ^ ARG001
9 |     return 0
  |

src\temp.py:8:24: ARG001 Unused function argument: `b`
  |
6 | @overload
7 | def func(a: int, b: str) -> int: ...
8 | def func(a: int | str, b: int | str) -> int:
  |                        ^ ARG001
9 |     return 0
  |

Found 4 errors.

Version

ruff 0.12.5 (d13228a 2025-07-24)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingruleImplementing 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