-
Notifications
You must be signed in to change notification settings - Fork 35
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
Simplify GlobusAuthRequiremenetsError validation #795
Simplify GlobusAuthRequiremenetsError validation #795
Commits on Aug 4, 2023
-
Begin converting GARE to annotated validators
This is an experimental change to an experimental subpackage. Rather than explicitly enumerating types 3x between - class declaration - SUPPORTED_FIELDS dict - init declaration and then auto-lifting `locals()` values into assignments, take a slightly different tack of enumerating the types twice - class declaration with Annotated - init declaration And then manually assigning fields (pylint will keep us honest about missing parameters). A new set of validator helpers cover our needs in terms of picking up and using the validators.
Configuration menu - View commit details
-
Copy full SHA for 5fb4733 - Browse repository at this point
Copy the full SHA 5fb4733View commit details -
GARE validators support a 'DEFAULT' rule
If a 'DEFAULT' sentinel value is seen in the Annotated data, then the type from the annotation can be mapped to a known validator. Bake this logic into the validators.
Configuration menu - View commit details
-
Copy full SHA for 2ba3166 - Browse repository at this point
Copy the full SHA 2ba3166View commit details -
Refactor GARE validators to protocol system
Declare a well-typed protocol for validators, which defines the `__call__` method to take a name (for the field) and a value to validate. Each field validation is now done with an explicit call to a validator, and without any derivation of validators, types, or meta-programming. The tow remaining items which needed special handling were: - checking for non-null values being passed for at least one argument - loading a data object from a dict filtering out extra params In these two cases, the desired arg names are found by examining `__init__` and excluding `self` and `extra`, each of which has special meaning. In general, the paradigm shift offered here is to be more direct and explicit, even if the requirement is that we are verbose in the process. Partly, this was based on the realization that many of the meta-programming techniques being used were not resulting in the desired level of brevity and clarity.
Configuration menu - View commit details
-
Copy full SHA for 4b9585b - Browse repository at this point
Copy the full SHA 4b9585bView commit details -
Revert '--keep-runtime-typing' from prior impl
An aborted implementation of annotation-based validators required that we preserve runtime typing. That constraint is gone, meaning we don't need the relevant flag for pre-commit.
Configuration menu - View commit details
-
Copy full SHA for d69a86f - Browse repository at this point
Copy the full SHA d69a86fView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7ffbd01 - Browse repository at this point
Copy the full SHA 7ffbd01View commit details -
Remove runtime use of signature inspection
Relegate the strategy of looking at `__init__` signatures to the testsuite. Rather than doing this at runtime, reintroduce `SUPPORTED_FIELDS` as a property of GARE-related classes, but as a set of strings. The testsuite now checks the set against `__init__` for the relevant class. The result is more verbose but simpler.
Configuration menu - View commit details
-
Copy full SHA for 768922f - Browse repository at this point
Copy the full SHA 768922fView commit details
Commits on Aug 5, 2023
-
Carefully apply
inspect
to GARE validators- Deriving a value from the `locals()` of a parent frame saves us some redundancy and is safe so long as the relevant helper remains purely internal - Inspecting an `__init__` signature is simple and easy if it is done in the class declaration context when `__init__` is "just a function" and not yet bound to the class. No complex derivation of the `__init__` function is therefore needed In order for this to work, `HasSupportedFields` needs to become an explicit Protocol, or mypy incorrectly fails some of the variants.
Configuration menu - View commit details
-
Copy full SHA for d3ef171 - Browse repository at this point
Copy the full SHA d3ef171View commit details