-
Notifications
You must be signed in to change notification settings - Fork 2
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
Semantics generic parent #544
base: mypy_semantics
Are you sure you want to change the base?
Conversation
An interface class guaranteeing the (Any-typed) attribute is too vague to be super useful, and redundant when it's _only_ used in `Semantic`. Having a `parent` will just be a direct feature of being semantic. Signed-off-by: liamhuber <[email protected]>
Signed-off-by: liamhuber <[email protected]>
Signed-off-by: liamhuber <[email protected]>
Because of the label arg vs kwarg problem, there is still a vestigial label arg in the SemanticParent init signature. Signed-off-by: liamhuber <[email protected]>
This is handled in the super class Signed-off-by: liamhuber <[email protected]>
Signed-off-by: liamhuber <[email protected]>
Signed-off-by: liamhuber <[email protected]>
Signed-off-by: liamhuber <[email protected]>
Signed-off-by: liamhuber <[email protected]>
Signed-off-by: liamhuber <[email protected]>
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
Signed-off-by: liamhuber <[email protected]>
|
Some refactoring, namely getting rid of the
HasParent
interface (which was only used in a single place,Semantic
, which can simply have that as part of its interface) and breakingSemanticParent
out of theSemantic
inheritance tree. These made it easier to then makeSemantic
generic on its parent type, so that type narrowing inNode(..., Semantic["Composite"], ...)
gives us helpful type narrowing.I think
mypy --strict
will still complain about the typevar definitions,This is because the bounds are generic and we leave the resolution implicitly as
typing.Any
. At present I'm not concerned about this because (a) let's getmypy
happy before worrying aboutmypy --strict
, and (b) because of the circular way thatSemantic(Generic[ParentType])
andSemanticParent(Generic[ChildType])
, I think we are anyhow actually achievingeven though we obviously can't actually write that out.
TODO: Take a swing at delaying the specification of
Semantic
's generic type inNode
, such that we don't need explicit handling of the parent-most behaviour ofWorkflow
, but can do something likeWorkflow[Node[None]]
, whileStaticNode[Node[Composite]]
continues to behave in the current way. (It might be necessary to delay this until #360 is resolved and we can directly sayWorkflow[Semantic[None]]
andNode[Semantic[Composite]]
(or similar).