Skip to content

Commit e4e8780

Browse files
committed
fix: remove beartype decorators
1 parent bd32054 commit e4e8780

File tree

10 files changed

+28
-30
lines changed

10 files changed

+28
-30
lines changed

docs/docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Fix
44

5+
- remove unnecessary dependency on Pydantic
6+
- expand ~/
57
- and support 'levelname'
68
- support 'time'
79
- drop support for Python 3.8

docs/docs/CODE_TAG_SUMMARY.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Collected Code Tags
22

3-
| Type | Comment | Last Edit | Source File |
4-
|---------|------------------------------------------------------------------|------------|------------------------------------------------------------------------------------------------------------------------------------------|
5-
| PLANNED | Add a flag (--debug & store_true) to print debugging information | 2023-02-02 | [tail_jsonl/scripts.py:31](https://github.com/KyleKing/tail-jsonl/blame/fd15e5907afae783ba21bb0f9d310cc6b08008c4/tail_jsonl/main.py#L34) |
3+
| Type | Comment | Last Edit | Source File |
4+
|---------|------------------------------------------------------------------|------------|-------------------------------------------------------------------------------------------------------------------------------------------|
5+
| PLANNED | temporary backward compatibility until part of Corallium | 2024-10-05 | [tail_jsonl/config.py:10](https://github.com/KyleKing/tail-jsonl/blame/bd32054c9276da9dba500cb7c1289061f4e0ada1/tail_jsonl/config.py#L10) |
6+
| PLANNED | Add a flag (--debug & store_true) to print debugging information | 2023-02-02 | [tail_jsonl/scripts.py:29](https://github.com/KyleKing/tail-jsonl/blame/fd15e5907afae783ba21bb0f9d310cc6b08008c4/tail_jsonl/main.py#L34) |
67

7-
Found code tags for PLANNED (1)
8+
Found code tags for PLANNED (2)
89

910
<!-- calcipy_skip_tags -->

docs/docs/DEVELOPER_GUIDE.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ poetry config pypi-token.pypi ...
4949
|-------------------------------------------|------------|---------|----------|----------|
5050
| `tail_jsonl/__init__.py` | 4 | 0 | 0 | 100.0% |
5151
| `tail_jsonl/_private/__init__.py` | 0 | 0 | 0 | 100.0% |
52-
| `tail_jsonl/_private/core.py` | 49 | 1 | 0 | 94.0% |
53-
| `tail_jsonl/_runtime_type_check_setup.py` | 13 | 0 | 33 | 100.0% |
54-
| `tail_jsonl/config.py` | 11 | 0 | 0 | 100.0% |
55-
| `tail_jsonl/scripts.py` | 17 | 0 | 19 | 94.7% |
56-
| **Totals** | 94 | 1 | 52 | 95.9% |
52+
| `tail_jsonl/_private/core.py` | 45 | 1 | 0 | 92.5% |
53+
| `tail_jsonl/_runtime_type_check_setup.py` | 14 | 0 | 33 | 100.0% |
54+
| `tail_jsonl/config.py` | 23 | 0 | 0 | 90.2% |
55+
| `tail_jsonl/scripts.py` | 16 | 0 | 18 | 94.4% |
56+
| **Totals** | 102 | 1 | 51 | 93.1% |
5757

58-
Generated on: 2024-10-04
58+
Generated on: 2024-10-05
5959
<!-- {cte} -->

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ ignore = [
7878
'ANN003', # Missing type annotation for `**kwargs`
7979
'ANN101', # Missing type annotation for `self` in method (automatically inferred)
8080
'ANN102', # Missing type annotation for `cls` in classmethod (automatically inferred)
81+
'ANN401', # Dynamically typed expressions (typing.Any) are disallowed in `pop_key`
8182
'BLE001', # Do not catch blind exception: `Exception`
8283
'CPY001', # Missing copyright notice at top of file
8384
'D203', # "1 blank line required before class docstring" (Conflicts with D211)
@@ -87,6 +88,9 @@ ignore = [
8788
'FIX002', # Line contains TODO
8889
'FIX004', # Line contains HACK
8990
'PLR0913', # Too many arguments in function definition (6 > 5)
91+
'TCH001', # Move application import `tail_jsonl.config.Config` into a type-checking block (Conflicts with Beartype)
92+
'TCH002', # Move third-party import `rich.console.Console` into a type-checking block (Conflicts with Beartype)
93+
'TCH003', # Move standard library import `argparse` into a type-checking block (Conflicts with Beartype)
9094
'TD001', # Invalid TODO tag: `FIXME`
9195
'TD002', # Missing author in TODO; try: `# TODO(<author_name>): ...`
9296
'TD003', # Missing issue link on the line following this TODO

tail_jsonl/_private/core.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99
from typing import Any
1010

1111
import dotted # type: ignore[import-untyped]
12-
from beartype import beartype
1312
from corallium.loggers.rich_printer import rich_printer
1413
from corallium.loggers.styles import get_level
1514
from rich.console import Console
1615

1716
from tail_jsonl.config import Config
1817

1918

20-
2119
def _dot_pop(data: dict, key: str) -> str | None: # type: ignore[type-arg]
2220
value = dotted.get(data, key)
2321
if isinstance(value, str):
@@ -26,7 +24,6 @@ def _dot_pop(data: dict, key: str) -> str | None: # type: ignore[type-arg]
2624
return None
2725

2826

29-
3027
def _pop_key(data: dict, keys: list[str], fallback: str) -> Any: # type: ignore[type-arg]
3128
"""Return result of recursively popping each key while searching for a match."""
3229
try:
@@ -36,7 +33,6 @@ def _pop_key(data: dict, keys: list[str], fallback: str) -> Any: # type: ignore
3633
return _dot_pop(data, key) or _pop_key(data, keys, fallback)
3734

3835

39-
4036
def pop_key(data: dict, keys: list[str], fallback: str) -> Any: # type: ignore[type-arg]
4137
"""Return the first key in the data or default to the fallback."""
4238
return _pop_key(data, copy(keys), fallback)
@@ -52,7 +48,6 @@ class Record:
5248
data: dict # type: ignore[type-arg]
5349

5450
@classmethod
55-
5651
def from_line(cls, data: dict, config: Config) -> Record: # type: ignore[type-arg]
5752
"""Return Record from jsonl."""
5853
return cls(
@@ -63,7 +58,6 @@ def from_line(cls, data: dict, config: Config) -> Record: # type: ignore[type-a
6358
)
6459

6560

66-
6761
def print_record(line: str, console: Console, config: Config) -> None:
6862
"""Format and print the record."""
6963
try:

tail_jsonl/_runtime_type_check_setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Configure runtime typechecking conditionally."""
22

3+
from __future__ import annotations
4+
35
from datetime import datetime, timezone
46
from enum import Enum
57
from os import getenv

tail_jsonl/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
# PLANNED: temporary backward compatibility until part of Corallium
11-
def styles_from_dict(data: dict) -> Styles:
11+
def styles_from_dict(data: dict) -> Styles: # type: ignore[type-arg]
1212
"""Return Self instance."""
1313
if colors := (data.pop('colors', None) or None):
1414
colors = Colors(**colors)
@@ -26,7 +26,7 @@ class Keys:
2626
on_own_line: list[str] = field(default_factory=lambda: ['text', 'exception'])
2727

2828
@classmethod
29-
def from_dict(cls, data: dict) -> Keys:
29+
def from_dict(cls, data: dict) -> Keys: # type: ignore[type-arg]
3030
"""Return Self instance."""
3131
return cls(**data)
3232

@@ -39,7 +39,7 @@ class Config:
3939
keys: Keys = field(default_factory=Keys)
4040

4141
@classmethod
42-
def from_dict(cls, data: dict) -> Config:
42+
def from_dict(cls, data: dict) -> Config: # type: ignore[type-arg]
4343
"""Return Self instance."""
4444
return cls(
4545
styles=styles_from_dict(data.get('styles', {})),

tail_jsonl/scripts.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""Start the command line program."""
22

3+
from __future__ import annotations
4+
35
import argparse
46
import fileinput
57
import sys
68
from pathlib import Path
79

8-
from beartype import beartype
9-
from beartype.typing import Dict, Optional
1010
from corallium.tomllib import tomllib
1111
from rich.console import Console
1212

@@ -15,17 +15,15 @@
1515
from .config import Config
1616

1717

18-
@beartype
19-
def _load_config(config_path: Optional[str]) -> Config:
18+
def _load_config(config_path: str | None) -> Config:
2019
"""Return loaded specified configuration file."""
21-
user_config: Dict = {} # type: ignore[type-arg]
20+
user_config: dict = {} # type: ignore[type-arg]
2221
if config_path:
2322
pth = Path(config_path).expanduser()
2423
user_config = tomllib.loads(pth.read_text(encoding='utf-8'))
2524
return Config.from_dict(user_config)
2625

2726

28-
@beartype
2927
def start() -> None: # pragma: no cover
3028
"""CLI Entrypoint."""
3129
# PLANNED: Add a flag (--debug & store_true) to print debugging information

tests/_private/test_core.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@
2626
import platform
2727

2828
import pytest
29-
from beartype import beartype
30-
from beartype.typing import List
3129
from rich.console import Console
3230

3331
from tail_jsonl._private.core import print_record
3432
from tail_jsonl.config import Config
3533
from tests.configuration import TEST_DATA_DIR
3634

3735

38-
@beartype
39-
def read_logs() -> List[str]:
36+
def read_logs() -> list[str]:
4037
return (TEST_DATA_DIR / 'logs.jsonl').read_text(encoding='utf-8').strip().split('\n')
4138

4239

tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .configuration import TEST_DATA_DIR
77

88

9-
def test_core_escapping_dot_notation(console: Console):
9+
def test_core_escapping_dot_notation(console: Console) -> None:
1010
config = _load_config(str(TEST_DATA_DIR / 'test-dot-notation.toml'))
1111
print_record('{"this.message": "this-dot-message", "this.key": "key"}', console, config)
1212

0 commit comments

Comments
 (0)