Skip to content

False positive bad-argument-type when calling a method with AnyStr #2644

@superbobry

Description

@superbobry

Describe the Bug

Reproducer:

from typing import AnyStr

class A:
  @classmethod
  def create(cls, x: AnyStr | None): ...


def test(x: AnyStr | None):
  A.create(x)

Output:

ERROR Argument `AnyStr | None` is not assignable to parameter `x` with type `str | None` in function `A.create` [bad-argument-type]
  --> /tmp/foo.py:10:12
   |
10 |   A.create(x)

It looks like AnyStr is specialized to str? Possibly a duplicate of #2370.

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Labels

googleissues from googletypecheckingv1-verifiedIn both V1 milestone and top-ranked (verified by ranking pipeline)

Type

No fields configured for Bug.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions