1
1
# mypy: allow-untyped-defs
2
2
"""local path implementation."""
3
+
3
4
from __future__ import annotations
4
5
5
6
import atexit
@@ -205,12 +206,10 @@ class Stat:
205
206
if TYPE_CHECKING :
206
207
207
208
@property
208
- def size (self ) -> int :
209
- ...
209
+ def size (self ) -> int : ...
210
210
211
211
@property
212
- def mtime (self ) -> float :
213
- ...
212
+ def mtime (self ) -> float : ...
214
213
215
214
def __getattr__ (self , name : str ) -> Any :
216
215
return getattr (self ._osstatresult , "st_" + name )
@@ -225,7 +224,7 @@ def owner(self):
225
224
raise NotImplementedError ("XXX win32" )
226
225
import pwd
227
226
228
- entry = error .checked_call (pwd .getpwuid , self .uid ) # type:ignore[attr-defined]
227
+ entry = error .checked_call (pwd .getpwuid , self .uid ) # type:ignore[attr-defined,unused-ignore ]
229
228
return entry [0 ]
230
229
231
230
@property
@@ -235,7 +234,7 @@ def group(self):
235
234
raise NotImplementedError ("XXX win32" )
236
235
import grp
237
236
238
- entry = error .checked_call (grp .getgrgid , self .gid ) # type:ignore[attr-defined]
237
+ entry = error .checked_call (grp .getgrgid , self .gid ) # type:ignore[attr-defined,unused-ignore ]
239
238
return entry [0 ]
240
239
241
240
def isdir (self ):
@@ -253,15 +252,15 @@ def getuserid(user):
253
252
import pwd
254
253
255
254
if not isinstance (user , int ):
256
- user = pwd .getpwnam (user )[2 ] # type:ignore[attr-defined]
255
+ user = pwd .getpwnam (user )[2 ] # type:ignore[attr-defined,unused-ignore ]
257
256
return user
258
257
259
258
260
259
def getgroupid (group ):
261
260
import grp
262
261
263
262
if not isinstance (group , int ):
264
- group = grp .getgrnam (group )[2 ] # type:ignore[attr-defined]
263
+ group = grp .getgrnam (group )[2 ] # type:ignore[attr-defined,unused-ignore ]
265
264
return group
266
265
267
266
@@ -318,7 +317,7 @@ def chown(self, user, group, rec=0):
318
317
def readlink (self ) -> str :
319
318
"""Return value of a symbolic link."""
320
319
# https://github.com/python/mypy/issues/12278
321
- return error .checked_call (os .readlink , self .strpath ) # type: ignore[arg-type,return-value]
320
+ return error .checked_call (os .readlink , self .strpath ) # type: ignore[arg-type,return-value,unused-ignore ]
322
321
323
322
def mklinkto (self , oldname ):
324
323
"""Posix style hard link to another name."""
@@ -757,15 +756,11 @@ def open(self, mode="r", ensure=False, encoding=None):
757
756
if ensure :
758
757
self .dirpath ().ensure (dir = 1 )
759
758
if encoding :
760
- # Using type ignore here because of this error:
761
- # error: Argument 1 has incompatible type overloaded function;
762
- # expected "Callable[[str, Any, Any], TextIOWrapper]" [arg-type]
763
- # Which seems incorrect, given io.open supports the given argument types.
764
759
return error .checked_call (
765
760
io .open ,
766
761
self .strpath ,
767
762
mode ,
768
- encoding = encoding , # type:ignore[arg-type]
763
+ encoding = encoding ,
769
764
)
770
765
return error .checked_call (open , self .strpath , mode )
771
766
@@ -966,12 +961,10 @@ def ensure(self, *args, **kwargs):
966
961
return p
967
962
968
963
@overload
969
- def stat (self , raising : Literal [True ] = ...) -> Stat :
970
- ...
964
+ def stat (self , raising : Literal [True ] = ...) -> Stat : ...
971
965
972
966
@overload
973
- def stat (self , raising : Literal [False ]) -> Stat | None :
974
- ...
967
+ def stat (self , raising : Literal [False ]) -> Stat | None : ...
975
968
976
969
def stat (self , raising : bool = True ) -> Stat | None :
977
970
"""Return an os.stat() tuple."""
@@ -1277,13 +1270,7 @@ def mkdtemp(cls, rootdir=None):
1277
1270
1278
1271
if rootdir is None :
1279
1272
rootdir = cls .get_temproot ()
1280
- # Using type ignore here because of this error:
1281
- # error: Argument 1 has incompatible type overloaded function; expected "Callable[[str], str]" [arg-type]
1282
- # Which seems incorrect, given tempfile.mkdtemp supports the given argument types.
1283
- path = error .checked_call (
1284
- tempfile .mkdtemp ,
1285
- dir = str (rootdir ), # type:ignore[arg-type]
1286
- )
1273
+ path = error .checked_call (tempfile .mkdtemp , dir = str (rootdir ))
1287
1274
return cls (path )
1288
1275
1289
1276
@classmethod
0 commit comments