Skip to content

Comments

Fix name mangling and typevar errors (dev branch)#929

Merged
taylorfturner merged 3 commits intocapitalone:devfrom
junholee6a:fix-name-mangle-error-dev
Jul 5, 2023
Merged

Fix name mangling and typevar errors (dev branch)#929
taylorfturner merged 3 commits intocapitalone:devfrom
junholee6a:fix-name-mangle-error-dev

Conversation

@junholee6a
Copy link
Contributor

Issue: #722

Inside the BaseDataProcessor class definition, all references to __subclasses are automatically replaced with
_BaseDataProcessor__subclasses. This remains the case even in static methods _register_subclass() and get_class(). Same with BaseModel and its __subclasses field. So we do not have to write out the full name mangled identifiers inside the class definitions.

Also, mypy doesn't seem to be able to handle the return type of BaseDataProcessor.get_class() being a typevar, so that was changed to type[BaseDataProcessor]. This does not affect the functionality of get_class() since it always returns a subclass of BaseDataProcessor.

This PR is a duplicate of #895, except it is based on the dev branch instead of main

Inside the BaseDataProcessor class definition, references to
__subclasses are automatically replaced with
_BaseDataProcessor__subclasses. This remains the case even in static
methods _register_subclass() and get_class(). Same with BaseModel and
its __subclasses field. So we do not have to write out the full name
mangled identifiers inside the class definitions.

Also, mypy doesn't seem to be able to handle the return type of
BaseDataProcessor.get_class() being a typevar, so that was changed to
type[BaseDataProcessor]. This does not affect the functionality of
get_class() since it always returns a subclass of BaseDataProcessor.
@junholee6a
Copy link
Contributor Author

junholee6a commented Jul 2, 2023

Whitesource license is stuck in "expected" status, so I'll push an empty commit

"""For labeling data."""

_BaseModel__subclasses: dict[str, type[BaseModel]] = {}
__subclasses: dict[str, type[BaseModel]] = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool and portable

@taylorfturner taylorfturner merged commit c1abee6 into capitalone:dev Jul 5, 2023
taylorfturner added a commit that referenced this pull request Jul 5, 2023
@taylorfturner
Copy link
Contributor

Need to revert to ensure dev is updated to main before we continue additional PRs to dev or feature/* branching off dev. @junholee6a -- not your fault. If you can, just rebase / cherry pick your commits here on dev once I update things. I'll pop another comment here once its ready to go

@taylorfturner
Copy link
Contributor

The idea here is that we will take current dev and rename it to something like dev/release/0.10.0. But since we are going to re-create dev from main we would loose your changes in the "new" dev branch. Hopefully that is helpful in adding a bit more clarity. Thanks!

@taylorfturner
Copy link
Contributor

Okay -- good to go on a re-open @junholee6a into dev. Thanks again!

@junholee6a
Copy link
Contributor Author

Okay -- good to go on a re-open @junholee6a into dev. Thanks again!

Thanks for the heads up, I just re-made the branch and PR

@junholee6a junholee6a deleted the fix-name-mangle-error-dev branch July 23, 2023 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

static_typing mypy static typing issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants