Skip to content

Commit ab2350a

Browse files
committed
build: copier-auto-update
1 parent 213416e commit ab2350a

8 files changed

+76
-59
lines changed

.copier-answers.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Answer file maintained by Copier for: https://github.com/KyleKing/calcipy_template
33
# DO NOT MODIFY THIS FILE. Edit by re-running copier and changing responses to the questions
44
# Check into version control.
5-
_commit: 1.10.4
5+
_commit: 1.10.7
66
_src_path: gh:KyleKing/calcipy_template
77
author_email: [email protected]
88
author_name: Kyle King

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ repos:
6969
# Note: this version must be the same as the hook revision
7070
7171
- "prettier-plugin-sh"
72-
exclude: \.copier-answers\.yml|tests/.*/cassettes/.*\.yaml
72+
exclude: \.copier-answers\.yml|tests/.*/cassettes/.*\.yaml|__snapshots__/.*\.json
7373
types_or: [html, javascript, json, shell, yaml]
7474
stages: ["pre-commit"]
7575
- repo: https://github.com/adrienverge/yamllint.git
@@ -86,7 +86,7 @@ repos:
8686
exclude: poetry\.lock|config_default.toml|demo_config.toml
8787
stages: ["pre-commit"]
8888
- repo: https://github.com/KyleKing/calcipy
89-
rev: 2.1.0
89+
rev: 3.0.1
9090
hooks:
9191
- id: copier-forbidden-files
9292
- id: lint-fix

pyproject.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ version = "1.2.5"
77
version_files = ["pyproject.toml:^version", "tail_jsonl/__init__.py:^__version"]
88

99
[tool.mypy]
10+
check_untyped_defs = true
1011
disallow_any_generics = true
1112
enable_error_code = ["ignore-without-code", "possibly-undefined", "redundant-expr", "truthy-bool"]
13+
extra_checks = true
14+
files = ["tail_jsonl", "tests"]
1215
no_implicit_reexport = true
1316
plugins = [
1417
"pydantic.mypy", # Most settings are from: https://pydantic-docs.helpmanual.io/mypy_plugin
@@ -20,6 +23,7 @@ strict_equality = true
2023
warn_no_return = true
2124
warn_redundant_casts = true
2225
warn_unreachable = true
26+
warn_unused_configs = true
2327
warn_unused_ignores = true
2428

2529
[tool.poetry]
@@ -68,7 +72,7 @@ init_typed = true
6872
warn_required_dynamic_aliases = true
6973

7074
[tool.pyright]
71-
include = ["tail_jsonl"]
75+
include = ["tail_jsonl", "tests"]
7276
pythonVersion = "3.9"
7377

7478
[tool.ruff]
@@ -107,7 +111,7 @@ unfixable = [
107111
inline-quotes = 'single'
108112

109113
[tool.ruff.lint.flake8-tidy-imports.banned-api]
110-
'invoke.collection.Collection'.msg = 'Use calcipy.cli.Collection instead.'
114+
'invoke.collection.Collection'.msg = 'Use calcipy.collection.Collection instead.'
111115
'invoke.tasks.task'.msg = 'Use calcipy.cli.task instead.'
112116
'typing.Callable'.msg = 'Use beartype.typing.* instead.'
113117
'typing.Dict'.msg = 'Use beartype.typing.* instead.'

tail_jsonl/__init__.py

+3-47
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,11 @@
11
"""tail_jsonl."""
22

3-
from datetime import datetime, timezone
4-
from enum import Enum
5-
from os import getenv
6-
from warnings import filterwarnings
7-
8-
from beartype import BeartypeConf
9-
from beartype.claw import beartype_this_package
10-
from beartype.roar import BeartypeDecorHintPep585DeprecationWarning
11-
from typing_extensions import Self
3+
from ._runtime_type_check_setup import configure_runtime_type_checking_mode
124

135
__version__ = '1.2.5'
146
__pkg_name__ = 'tail_jsonl'
157

16-
17-
class _RuntimeTypeCheckingModes(Enum):
18-
"""Supported global runtime type checking modes."""
19-
20-
ERROR = 'ERROR'
21-
WARNING = 'WARNING'
22-
OFF = None
23-
24-
@classmethod
25-
def from_environment(cls) -> Self: # pragma: no cover
26-
"""Return the configured mode."""
27-
rtc_mode = getenv('RUNTIME_TYPE_CHECKING_MODE') or None
28-
try:
29-
return cls(rtc_mode)
30-
except ValueError:
31-
modes = [_e.value for _e in cls]
32-
msg = f"'RUNTIME_TYPE_CHECKING_MODE={rtc_mode}' is not an allowed mode from {modes}"
33-
raise ValueError(msg) from None
34-
35-
36-
def configure_runtime_type_checking_mode() -> None: # pragma: no cover
37-
"""Optionally configure runtime type checking mode globally."""
38-
rtc_mode = _RuntimeTypeCheckingModes.from_environment()
39-
40-
if rtc_mode is not _RuntimeTypeCheckingModes.OFF:
41-
from beartype.roar import BeartypeClawDecorWarning # noqa: PLC0415
42-
43-
beartype_this_package(conf=BeartypeConf(
44-
warning_cls_on_decorator_exception=(
45-
None if rtc_mode is _RuntimeTypeCheckingModes.ERROR else BeartypeClawDecorWarning
46-
),
47-
))
48-
49-
50-
_PEP585_DATE = 2025
51-
if datetime.now(tz=timezone.utc).year <= _PEP585_DATE: # pragma: no cover
52-
filterwarnings('ignore', category=BeartypeDecorHintPep585DeprecationWarning)
538
configure_runtime_type_checking_mode()
549

55-
# ====== Above is the recommended code from calcipy_template and may be updated on new releases ======
10+
11+
# == Above code must always be first ==

tail_jsonl/_private/core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import logging
55
from copy import copy
66

7-
import dotted
7+
import dotted # type: ignore[import-untyped]
88
from beartype import beartype
99
from beartype.typing import Any, Dict, List, Optional
1010
from corallium.loggers.rich_printer import rich_printer
@@ -85,7 +85,7 @@ def print_record(line: str, console: Console, config: Config) -> None:
8585
}
8686
keys = set(printer_kwargs)
8787
rich_printer(
88-
**printer_kwargs,
88+
**printer_kwargs, # type: ignore[arg-type]
8989
# Ensure that there is no repeat keyword arguments
9090
**{f'_{key}' if key in keys else key: value for key, value in record.data.items()},
9191
)
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"""Configure runtime typechecking conditionally."""
2+
3+
from datetime import datetime, timezone
4+
from enum import Enum
5+
from os import getenv
6+
from warnings import filterwarnings
7+
8+
from beartype import BeartypeConf
9+
from beartype.claw import beartype_this_package
10+
from beartype.roar import BeartypeDecorHintPep585DeprecationWarning
11+
from typing_extensions import Self
12+
13+
14+
class _RuntimeTypeCheckingModes(Enum):
15+
"""Supported global runtime type checking modes."""
16+
17+
ERROR = 'ERROR'
18+
WARNING = 'WARNING'
19+
OFF = None
20+
21+
@classmethod
22+
def from_environment(cls) -> Self: # pragma: no cover
23+
"""Return the configured mode."""
24+
rtc_mode = getenv('RUNTIME_TYPE_CHECKING_MODE') or None
25+
try:
26+
return cls(rtc_mode)
27+
except ValueError:
28+
modes = [_e.value for _e in cls]
29+
msg = f"'RUNTIME_TYPE_CHECKING_MODE={rtc_mode}' is not from {modes}"
30+
raise ValueError(msg) from None
31+
32+
33+
def configure_runtime_type_checking_mode() -> None: # pragma: no cover
34+
"""Optionally configure runtime type checking mode globally."""
35+
rtc_mode = _RuntimeTypeCheckingModes.from_environment()
36+
37+
if rtc_mode is not _RuntimeTypeCheckingModes.OFF:
38+
from beartype.roar import BeartypeClawDecorWarning # noqa: PLC0415
39+
40+
beartype_this_package(
41+
conf=BeartypeConf(
42+
warning_cls_on_decorator_exception=(
43+
None
44+
if rtc_mode is _RuntimeTypeCheckingModes.ERROR
45+
else BeartypeClawDecorWarning
46+
),
47+
),
48+
)
49+
50+
51+
_PEP585_DATE = 2025
52+
if datetime.now(tz=timezone.utc).year <= _PEP585_DATE: # pragma: no cover
53+
filterwarnings(
54+
'ignore',
55+
category=BeartypeDecorHintPep585DeprecationWarning,
56+
)

tests/config_default.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ on_own_line = ["text", "exception"]
1919
timestamp = "#8DAAA1"
2020
message = "bold"
2121

22+
key = "#8DAAA1"
23+
value = "#A28EAB"
24+
value_own_line = "#AAA18D"
25+
26+
[styles.colors]
2227
level_error = "#e77d8f"
2328
level_warn = "#d8b172"
2429
level_info = "#a8cd76"
2530
level_debug = "#82a1f1"
2631
level_fallback = "#b69bf1"
27-
28-
key = "#8DAAA1"
29-
value = "#A28EAB"
30-
value_own_line = "#AAA18D"

tests/test_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pathlib import Path
22

3-
from corallium.tomllib import tomllib # type: ignore[no-redef]
3+
from corallium.tomllib import tomllib
44

55
from tail_jsonl.scripts import _load_config
66

0 commit comments

Comments
 (0)