-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unifies STRICT_TYPE_CONFORMANCE and DISABLE_TYPE_CONFORMANCE into `datatypes.config.COERCION`.
- Loading branch information
1 parent
9e6ea2b
commit da34e69
Showing
4 changed files
with
24 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
STRICT_TYPE_CONFORMANCE = False | ||
"""Whether to raise an error or just warn when a type is incomplete. | ||
import enum, typing | ||
|
||
Setting this to True might screw you over if SRC decide to remove parts of a type.""" | ||
class CoercionLevel(enum.IntEnum): | ||
DISABLED = -1 | ||
ENABLED = 0 | ||
STRICT = 1 | ||
|
||
DISABLE_TYPE_CONFORMANCE = False | ||
"""Whether to automatically convert calls and nested datatypes from dictionaries to their typed equivalents. | ||
COERCION: typing.Union[CoercionLevel, int] = 0 | ||
"""How aggressively to enforce type coercion. | ||
Will probably improve performance on responses that retrieve a lot of data.""" | ||
|
||
#TODO: combine into single param, since Strict does nothing when Disabled | ||
|
||
SUPPRESS_FIELD_WARNINGS = False | ||
"""Suppress warnings that a type is """ | ||
-1: Disabled; types will not be coerced. WARN: field accessors will break! | ||
0: Enabled; types will be coerced. Sends log warnings on incomplete types. | ||
1: Strict; types will be coerced. Raises errors on incomplete types. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters