Skip to content

Deprecate most ValidateInStrings validators. - #16483

Merged
timhoffm merged 1 commit into
matplotlib:masterfrom
anntzer:vsil
Feb 16, 2020
Merged

timhoffm merged 1 commit into
matplotlib:masterfrom
anntzer:vsil

Conversation

@anntzer

@anntzer anntzer commented Feb 12, 2020

Copy link
Copy Markdown
Contributor

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

@tacaswell tacaswell left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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

anntzer commented Feb 13, 2020

Copy link
Copy Markdown
Contributor Author

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

anntzer commented Feb 13, 2020

Copy link
Copy Markdown
Contributor Author

(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