Skip to content
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

Switch metaclass to __init_subclass__ ? #3061

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LecrisUT
Copy link
Contributor

I am mostly considering the comment

        # TODO: repeat type annotation from `Common` - IIUIC, `cls` should be
        # the class being created, in our case that would be a subclass of
        # `Common`. For some reason, mypy is uncapable of detecting annotation
        # of this attribute in `Common`, and infers its type is `None` because
        # of the assignment below. That's incomplete, and leads to mypy warning
        # about assignments of `CliInvocation` instances to this attribute.
        # Repeating the annotation silences mypy, giving it better picture.

But not sure I quite understand what is meant with the comment.

@LecrisUT LecrisUT force-pushed the feat/init_subclass branch from e28f49a to 2989550 Compare June 29, 2024 00:01
@abitrolly
Copy link
Contributor

Generic, Common, Base doesn't tell anything about what parent class provides.

If there are just some utility methods, I would prefer composition over inheritance.

@LecrisUT
Copy link
Contributor Author

Generic, Common, Base doesn't tell anything about what parent class provides.

If there are just some utility methods, I would prefer composition over inheritance.

Interesting proposal. This would only apply to components like Common, Whereable etc. Although there should still be at least one base class where to put the fmf logic.

Can this work in tandom with json schemas? E.g. to have something dynamic like the plans-plugins. If so 👍 for such approach as a tool to breakup the datastructure and json schemas.

tmt/tmt/utils.py

Lines 5623 to 5642 in 986e7fe

for step in ('discover', 'execute', 'finish', 'prepare', 'provision', 'report'):
step_schema_prefix = f'/schemas/{step}/'
step_plugin_schema_ids = [schema_id for schema_id in store if schema_id.startswith(
step_schema_prefix) and schema_id not in PLAN_SCHEMA_IGNORED_IDS]
refs: list[Schema] = [
{'$ref': schema_id} for schema_id in step_plugin_schema_ids
]
schema['properties'][step] = {
'oneOf': [*refs,
{
'type': 'array',
'items': {
'anyOf': refs
}
}
]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants