-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MNT: Type-annotate Pydra #648
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #648 +/- ##
==========================================
- Coverage 81.77% 81.57% -0.20%
==========================================
Files 20 20
Lines 4394 4397 +3
Branches 1264 0 -1264
==========================================
- Hits 3593 3587 -6
- Misses 797 810 +13
+ Partials 4 0 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Okay, it looks like we're going to have fights with type checkers about @djarecka What exactly are the semantics of these? It looks like they are labels but not actually instantiable as classes containing paths, so when we write things like @task
def dirname(a: File) -> Directory:
return Path(a).parent We get a type failure. And we can't wrap One possibility could be to just implement a very thin class FileObj:
def __init__(self, path: ty.Union[str, os.PathLike]):
self._path = Path(path)
def __fspath__(self):
return str(self._path)
def __repr__(self):
return repr(self._path)
class File(FileObj): ...
class Directory(FileObj): ... I think this would get us close enough to 3.10-style NewTypes, so we could eventually get rid of these. But it may make more sense to get rid of/deprecate these concepts altogether. |
I think I'm not sure what you mean by "concept" that we might want to get rid of. |
Sorry, I just meant the classes. I'm not sure how all they're used, so it's unclear what we need to replace if we just delete them. |
I'd propose to define Anything satisfying |
We also need to make sure we would not be accidentally breaking pieces of formatting or callable logic like this which relies on isinstance / pattern matching on types. |
@effigies - I mostly used them in Input/Output spec so it's clear what people expect to get. I also use this type when doing the current hashing of setting the bindings to the container. Not saying that it would be impossible without them, but not sure if I want to remove them completely... Can think more |
Given the major changes recently introduced, do you think it's worth keeping this PR open? |
No. |
Types of changes
Summary
Building off of #621. Interested in feedback as we go.
Checklist