-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
In 1.11.0, classes that inherit from os.PathLike could be used with os.path methods. As of 3.12, these methods claim to accept "any object implementing the os.PathLike protocol". However, in 1.12.0, mypy emits an error.
To Reproduce
import os
class MyPath(os.PathLike):
def __init__(self, path: str):
super().__init__()
self.path = path
def __fspath__(self):
return self.path
print(os.path.abspath(MyPath(".")))Expected Behavior
Unless I'm missing something, MyPath should be valid to pass, no?
Actual Behavior
pathlike.py:13: error: Value of type variable "AnyStr" of "abspath" cannot be "MyPath | Any"
Your Environment
- Mypy version used: 1.12.0
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: 3.12
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong