Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecate most ValidateInStrings validators. #16483

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

Merged
merged 1 commit into from
Feb 16, 2020
Merged

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Feb 12, 2020

We can just list the allowed string values in the defaultParams
dict (which is actually clearer) and then dynamically generate
the corresponding validators; no need to expose them as separate
public API (which is not particularly useful anyways because how can
you know that it's validate_fontset for mathtext.fontset, but
validate_mathtext_default for mathtext.default?).

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

👍 in principle, it does read much better.

The _fix_validators() which works by mutating global state as a side effect is a bit annoying, but I don't see a better option.

Maybe delete the function after we call it and leave a comment about why we need to have it?

@tacaswell
Copy link
Member

I did not carefully check that the lists of strings were copied correctly.

We can just list the allowed string values in the defaultParams
dict (which is actually clearer) and then dynamically generate
the corresponding validators; no need to expose them as separate
public API (which is not particularly useful anyways because how can
you know that it's `validate_fontset` for `mathtext.fontset`, but
`validate_mathtext_default` for `mathtext.default`?).
@anntzer
Copy link
Contributor Author

anntzer commented Feb 13, 2020

Actually it's not too hard to do without the helper function (and without leaking any temporary variables), it's just a dict comprehension. Edited accordingly.

@anntzer
Copy link
Contributor Author

anntzer commented Feb 13, 2020

(I didn't touch the case-insensitive ones yet because I haven't decided the best way to handle them, but it could be as simple as [_case_insensitive_marker_object, "blah", "blah"] which I think would still be an improvement readabililty-wise -- the marker object wouldn't leak out anyways as it'd be immediately consumed by the conversion to ValidateInStrings.)

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

Successfully merging this pull request may close these issues.

3 participants