Commit c34a466
committed
Have Repo.__init__ convert epath to str first instead
In e133018 before this, I had noticed that Repo.__init__ implicitly
relied on the implementation detail of cygpath that it converts its
argument to str immediately. That detail was not reflected in the
parameter type annotation, which could've been broader, so I had
fixed the mypy error in Repo.__init__ by broadening cygpath's
parameter type annotation.
This undoes that change, putting the cygpath annotations back as
before, and fixes the mypy error in another way, by having
Repo.__init__ pass `str(epath)` instead of `epath` to cygpath.
The reason is the concern noted in the e133018 commit message,
that broadening the annotation made the way cygpath documents its
relationshp to Git.polish_url no longer correct, and that it is not
clear that the str(path) step in cygpath really ought to be made
more than an implementation detail (which if done may require some
documentation to be changed).
Instances of str are usually direct instances (rather than of a
subclass of str), in which case an extra call to str will (at least
in CPython, and probably in all implementations) just return the
same str object that was passed in. The performance penalty of this
extra call to str should therefore be extremely small.1 parent e133018 commit c34a466
2 files changed
+4
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
408 | 410 | | |
409 | 411 | | |
410 | 412 | | |
| |||
420 | 422 | | |
421 | 423 | | |
422 | 424 | | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | 425 | | |
429 | 426 | | |
430 | 427 | | |
| |||
0 commit comments