mypy icon indicating copy to clipboard operation
mypy copied to clipboard

no-untyped-def False Positive with attrs and an attr.ib converter

Open Redoubts opened this issue 3 years ago • 0 comments

Bug Report

New to 0.971 (vs .961), when you have an attrs class with a normal attr, and then another with a converter function, your class gets marked with error: Function is missing a type annotation for one or more arguments [no-untyped-def]

To Reproduce


@attr.s(auto_attribs=True, slots=True)
class Something:
    a: int
    desc: str = attr.ib(converter=lambda x: str(x))

Expected Behavior

No error

Actual Behavior

error: Function is missing a type annotation for one or more arguments [no-untyped-def]

Your Environment

  • Mypy version used: 0.971
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files):
[mypy]
platform = linux
ignore_missing_imports = true
follow_imports = silent
follow_imports_for_stubs = true
disallow_any_generics = true
disallow_incomplete_defs = true
disallow_subclassing_any = true
disallow_untyped_decorators = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_return_any = true
implicit_reexport = true
show_error_codes = True
  • Python version used: 3.8
  • Operating system and version: Debian 10.8

Redoubts avatar Aug 02 '22 00:08 Redoubts