diff --git a/.copier-answers.yml b/.copier-answers.yml index 602249c2..d926ce9c 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -2,7 +2,7 @@ # Answer file maintained by Copier for: https://github.com/KyleKing/calcipy_template # DO NOT MODIFY THIS FILE. Edit by re-running copier and changing responses to the questions # Check into version control. -_commit: 1.7.4 +_commit: 1.7.7 _src_path: gh:KyleKing/calcipy_template author_email: dev.act.kyle@gmail.com author_name: Kyle King diff --git a/calcipy/__init__.py b/calcipy/__init__.py index a36c955f..53e1ade4 100644 --- a/calcipy/__init__.py +++ b/calcipy/__init__.py @@ -11,8 +11,8 @@ __pkg_name__ = 'calcipy' -class _BeartypeModes(Enum): - """Supported global beartype modes.""" +class _RuntimeTypeCheckingModes(Enum): + """Supported global runtime type checking modes.""" ERROR = 'ERROR' WARNING = 'WARNING' @@ -21,36 +21,29 @@ class _BeartypeModes(Enum): @classmethod def from_environment(cls) -> Self: """Return the configured mode.""" - beartype_mode = getenv('BEARTYPE_MODE') or None + rtc_mode = getenv('CALCIPY_RUNTIME_TYPE_CHECKING_MODE') or None try: - return cls(beartype_mode) + return cls(rtc_mode) except ValueError: - msg = f"'BEARTYPE_MODE={beartype_mode}' is not an allowed mode from {[_e.value for _e in cls]}" - raise ValueError( - msg, - ) from None + modes = [_e.value for _e in cls] + msg = f"'CALCIPY_RUNTIME_TYPE_CHECKING_MODE={rtc_mode}' is not an allowed mode from {modes}" + raise ValueError(msg) from None -def configure_beartype() -> None: - """Optionally configure beartype globally.""" - beartype_mode = _BeartypeModes.from_environment() +def configure_runtime_type_checking_mode() -> None: + """Optionally configure runtime type checking mode globally.""" + rtc_mode = _RuntimeTypeCheckingModes.from_environment() - if beartype_mode != _BeartypeModes.OFF: - # PLANNED: Appease mypy and pyright, but this is a private import - from beartype.roar._roarwarn import _BeartypeConfReduceDecoratorExceptionToWarningDefault - beartype_warning_default = _BeartypeConfReduceDecoratorExceptionToWarningDefault + if rtc_mode != _RuntimeTypeCheckingModes.OFF: + from beartype.roar import BeartypeClawDecorWarning beartype_this_package(conf=BeartypeConf( warning_cls_on_decorator_exception=( - None if beartype_mode == _BeartypeModes.ERROR else beartype_warning_default + None if rtc_mode is _RuntimeTypeCheckingModes.ERROR else BeartypeClawDecorWarning ), - is_color=getenv('BEARTYPE_NO_COLOR') is not None), - ) + )) -configure_beartype() - -# ====== Above is the recommended code from calcipy_template and may be updated on new releases ====== - +configure_runtime_type_checking_mode() # ====== Above is the recommended code from calcipy_template and may be updated on new releases ====== diff --git a/docs/docs/CODE_TAG_SUMMARY.md b/docs/docs/CODE_TAG_SUMMARY.md index a37ffbbb..90c8951f 100644 --- a/docs/docs/CODE_TAG_SUMMARY.md +++ b/docs/docs/CODE_TAG_SUMMARY.md @@ -2,7 +2,6 @@ | Type | Comment | Last Edit | Source File | |---------|----------------------------------------------------------------------------------------------------|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| PLANNED | Appease mypy and pyright, but this is a private import | 2023-07-22 | [calcipy/__init__.py:39](https://github.com/KyleKing/calcipy/blame/9017346addc8c8bafd922d1c48e861f77a6ee0bc/calcipy/__init__.py#L39) | | TODO | If no stale, write out five oldest? | 2023-05-13 | [calcipy/check_for_stale_packages/_check_for_stale_packages.py:202](https://github.com/KyleKing/calcipy/blame/86c37cc4f24911db5562ef6fc8263102dbbcf5c5/calcipy/check_for_stale_packages/_check_for_stale_packages.py#L198) | | TODO | Can I type this function with fewer Any's? | 2023-05-17 | [calcipy/cli.py:173](https://github.com/KyleKing/calcipy/blame/efaaa73193296e1fa7e82f1e9a40253c5a26da2d/calcipy/cli.py#L173) | | TODO | Consider adding a configuration item for ignore_patterns | 2023-02-19 | [calcipy/file_search.py:82](https://github.com/KyleKing/calcipy/blame/e6bc0415e3bf6a6df5a9d808ce0e89d0f2c5df9e/calcipy/file_search.py#L82) | @@ -12,6 +11,6 @@ | TODO | Is there an easier way to maintain pytest parameter IDs? | 2023-02-17 | [tests/tasks/test_test.py:14](https://github.com/KyleKing/calcipy/blame/785b9d1c3afda6fc5a2e46f2bc7d41ed2614da09/tests/tasks/test_test.py#L11) | | PLANNED | Convert to hypothesis test! | 2023-02-19 | [tests/test_dot_dict.py:9](https://github.com/KyleKing/calcipy/blame/3f42ad855eb7024ff48af35d496633a87d4a14ac/tests/test_dot_dict.py#L9) | -Found code tags for TODO (7), PLANNED (2) +Found code tags for TODO (7), PLANNED (1) diff --git a/tests/__init__.py b/tests/__init__.py index 1393623c..74ea201f 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,3 +1,3 @@ from os import environ -environ['BEARTYPE_SHOW_WARNINGS'] = 'yes' +environ['CALCIPY_RUNTIME_TYPE_CHECKING_MODE'] = 'WARNING'