Commit e133018
committed
Broaden cygpath parameter annotation
To fix a mypy error in Repo.__init__ where the epath variable,
which can sometimes be a os.PathLike[str], does not match the str
annotation for cygpath's path parameter, even though cygwin
immediately calls str on that parameter.
Pulling most of cygpath out into a new helper function is to help
mypy correctly infer that the type of path is still compatible with
the return type of str, when it is used in the return statement.
I'm not sure this change is really the best solution at this time,
because while it fixes the mypy error (without creating a new one),
and cygpath is not listed in __all__, the docstring of advises to
call Git.polish_url instead of cygpath. That method is public,
annotates its parameter as str, and should not have its annotation
broadened without considernig if it makes sense to do so or if its
docstring needs to be updated.
So either the cygpath docstring should be updated or this change
should be undone and a different approach used to fix the type
error in Repo.__init__.1 parent f1cc1fe commit e133018
1 file changed
+6
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
408 | | - | |
409 | | - | |
| 407 | + | |
410 | 408 | | |
411 | 409 | | |
412 | 410 | | |
| |||
422 | 420 | | |
423 | 421 | | |
424 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
425 | 428 | | |
426 | 429 | | |
427 | 430 | | |
| |||
0 commit comments