-
Notifications
You must be signed in to change notification settings - Fork 138
Unify typing between df.Definition, features, and typing.NewType #188
Description
We want to make Definition
into a wrapper around https://docs.python.org/3/library/typing.html#newtype
Making sure it still supports the lock
and spec
keyword arguments.
dffml/feature/git/dffml_feature_git/feature/definitions.py
Lines 24 to 29 in a09d12b
Definition( | |
name="git_repository", | |
primitive="Dict[str, str]", | |
lock=True, | |
spec=GitRepoSpec, | |
), |
Then we need to go through all the operations and correct the types of their inputs:
dffml/feature/git/dffml_feature_git/feature/operations.py
Lines 105 to 108 in a09d12b
@op(inputs={"URL": URL}, outputs={"valid": valid_git_repository_URL}) | |
async def check_if_valid_git_repository_URL(URL: str): | |
exit_code = await exec_with_logging("git", "ls-remote", URL) | |
return {"valid": bool(exit_code == 0)} |
would become:
@op(inputs={"url": URL}, outputs={"valid": valid_git_repository_URL})
async def check_if_valid_git_repository_URL(url: URL):
exit_code = await exec_with_logging("git", "ls-remote", url)
return {"valid": bool(exit_code == 0)} p
The next issue that makes sense to do after this issue is #189
We need to be sure that static type checkers support this functionality. The TypeScript based one from Microsoft does not. Next type checkers we need to test are Google's one and mypy
.