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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid to use or register ClassVar #3209

Merged
merged 3 commits into from
Jan 8, 2022
Merged

Forbid to use or register ClassVar #3209

merged 3 commits into from
Jan 8, 2022

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Jan 7, 2022

Refs #2978
Refs #3201

I think that duplication is now pretty visible. Should I do something about it? 馃

@sobolevn
Copy link
Member Author

sobolevn commented Jan 7, 2022

I can't understand why mypy fails. The error message seems unhelpful.

@sobolevn
Copy link
Member Author

sobolevn commented Jan 7, 2022

Turns out, I've just missed this tiny line in the output 馃槅

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@Zac-HD Zac-HD merged commit cc1317e into master Jan 8, 2022
@Zac-HD Zac-HD deleted the classvar-type branch January 8, 2022 12:37
@Zac-HD
Copy link
Member

Zac-HD commented Jan 8, 2022

I think that duplication is now pretty visible. Should I do something about it? 馃

Yeah, at this point there seems to be a clear pattern. Next time (assuming it still makes sense), let's refactor to something like

for name, type_tuple in types.NON_RUNTIME_TYPES.items():
    if custom_type in type_tuple :
        raise InvalidArgument(
            f"custom_type={custom_type!r} is not allowed to be registered, "
            f"because there is no such thing as a runtime instance of {name}"
        )

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.

None yet

2 participants