Skip to content

Commit f88db3d

Browse files
authored
Drop Python 3.8 support (#1122)
1 parent aabf20e commit f88db3d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+672
-5093
lines changed

logfire/_internal/async_.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import asyncio.events
55
import asyncio.tasks
66
import inspect
7-
from contextlib import contextmanager
7+
from contextlib import AbstractContextManager, contextmanager
88
from pathlib import Path
99
from types import CoroutineType
10-
from typing import TYPE_CHECKING, Any, ContextManager
10+
from typing import TYPE_CHECKING, Any
1111

1212
from .constants import ONE_SECOND_IN_NANOSECONDS
1313
from .stack_info import StackInfo, get_code_object_info, get_stack_info_from_frame
@@ -19,7 +19,7 @@
1919
ASYNCIO_PATH = str(Path(asyncio.__file__).parent.absolute())
2020

2121

22-
def log_slow_callbacks(logfire: Logfire, slow_duration: float) -> ContextManager[None]:
22+
def log_slow_callbacks(logfire: Logfire, slow_duration: float) -> AbstractContextManager[None]:
2323
"""Log a warning whenever a function running in the asyncio event loop blocks for too long.
2424
2525
See Logfire.log_slow_async_callbacks.

logfire/_internal/auto_trace/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import sys
44
import warnings
5-
from typing import TYPE_CHECKING, Callable, Literal, Sequence
5+
from collections.abc import Sequence
6+
from typing import TYPE_CHECKING, Callable, Literal
67

78
from ..constants import ONE_SECOND_IN_NANOSECONDS
89
from .import_hook import LogfireFinder

logfire/_internal/auto_trace/import_hook.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
import ast
44
import sys
5+
from collections.abc import Iterator, Sequence
56
from dataclasses import dataclass
67
from importlib.abc import Loader, MetaPathFinder
78
from importlib.machinery import ModuleSpec
89
from importlib.util import spec_from_loader
910
from types import ModuleType
10-
from typing import TYPE_CHECKING, Any, Callable, Iterator, Sequence, cast
11+
from typing import TYPE_CHECKING, Any, Callable, cast
1112

1213
from ..utils import log_internal_error
1314
from .rewrite_ast import compile_source

logfire/_internal/auto_trace/rewrite_ast.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
import ast
44
import uuid
55
from collections import deque
6+
from contextlib import AbstractContextManager
67
from dataclasses import dataclass
78
from functools import partial
8-
from typing import TYPE_CHECKING, Any, Callable, ContextManager, TypeVar
9+
from typing import TYPE_CHECKING, Any, Callable, TypeVar
910

1011
import logfire
1112

@@ -35,7 +36,7 @@ def compile_source(
3536
Otherwise, it's initially the `partial` above.
3637
"""
3738
logfire_name = f'logfire_{uuid.uuid4().hex}'
38-
context_factories: list[Callable[[], ContextManager[Any]]] = []
39+
context_factories: list[Callable[[], AbstractContextManager[Any]]] = []
3940
tree = rewrite_ast(tree, filename, logfire_name, module_name, logfire_instance, context_factories, min_duration)
4041
assert isinstance(tree, ast.Module) # for type checking
4142
# dont_inherit=True is necessary to prevent the module from inheriting the __future__ import from this module.
@@ -54,7 +55,7 @@ def rewrite_ast(
5455
logfire_name: str,
5556
module_name: str,
5657
logfire_instance: Logfire,
57-
context_factories: list[Callable[[], ContextManager[Any]]],
58+
context_factories: list[Callable[[], AbstractContextManager[Any]]],
5859
min_duration: int,
5960
) -> ast.AST:
6061
logfire_args = LogfireArgs(logfire_instance._tags, logfire_instance._sample_rate) # type: ignore
@@ -69,7 +70,7 @@ class AutoTraceTransformer(BaseTransformer):
6970
"""Trace all encountered functions except those explicitly marked with `@no_auto_trace`."""
7071

7172
logfire_instance: Logfire
72-
context_factories: list[Callable[[], ContextManager[Any]]]
73+
context_factories: list[Callable[[], AbstractContextManager[Any]]]
7374
min_duration: int
7475

7576
def check_no_auto_trace(self, node: ast.FunctionDef | ast.AsyncFunctionDef | ast.ClassDef) -> bool:

logfire/_internal/auto_trace/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import annotations
22

33
import re
4+
from collections.abc import Sequence
45
from dataclasses import dataclass
5-
from typing import Sequence
66

77

88
@dataclass

logfire/_internal/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
import sys
1212
import warnings
1313
import webbrowser
14+
from collections.abc import Sequence
1415
from operator import itemgetter
1516
from pathlib import Path
16-
from typing import Any, Sequence, cast
17+
from typing import Any, cast
1718
from urllib.parse import urlparse
1819

1920
import requests

logfire/_internal/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
import sys
1010
import time
1111
import warnings
12+
from collections.abc import Sequence
1213
from contextlib import suppress
1314
from dataclasses import dataclass, field
1415
from pathlib import Path
1516
from threading import RLock, Thread
16-
from typing import TYPE_CHECKING, Any, Callable, Literal, Sequence, TypedDict, cast
17+
from typing import TYPE_CHECKING, Any, Callable, Literal, TypedDict, cast
1718
from urllib.parse import urljoin
1819
from uuid import uuid4
1920

logfire/_internal/config_params.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from dataclasses import dataclass
66
from functools import cached_property
77
from pathlib import Path
8-
from typing import Any, Callable, Literal, Set, TypeVar, Union
8+
from typing import Any, Callable, Literal, TypeVar, Union
99

1010
from opentelemetry.sdk.environment_variables import OTEL_SERVICE_NAME
1111
from typing_extensions import get_args, get_origin
@@ -88,9 +88,9 @@ class _DefaultCallback:
8888
"""Whether to enable/disable the console exporter."""
8989
PYDANTIC_PLUGIN_RECORD = ConfigParam(env_vars=['LOGFIRE_PYDANTIC_PLUGIN_RECORD'], allow_file_config=True, default='off', tp=PydanticPluginRecordValues)
9090
"""Whether instrument Pydantic validation.."""
91-
PYDANTIC_PLUGIN_INCLUDE = ConfigParam(env_vars=['LOGFIRE_PYDANTIC_PLUGIN_INCLUDE'], allow_file_config=True, default=set(), tp=Set[str])
91+
PYDANTIC_PLUGIN_INCLUDE = ConfigParam(env_vars=['LOGFIRE_PYDANTIC_PLUGIN_INCLUDE'], allow_file_config=True, default=set(), tp=set[str])
9292
"""Set of items that should be included in Logfire Pydantic plugin instrumentation."""
93-
PYDANTIC_PLUGIN_EXCLUDE = ConfigParam(env_vars=['LOGFIRE_PYDANTIC_PLUGIN_EXCLUDE'], allow_file_config=True, default=set(), tp=Set[str])
93+
PYDANTIC_PLUGIN_EXCLUDE = ConfigParam(env_vars=['LOGFIRE_PYDANTIC_PLUGIN_EXCLUDE'], allow_file_config=True, default=set(), tp=set[str])
9494
"""Set of items that should be excluded from Logfire Pydantic plugin instrumentation."""
9595
TRACE_SAMPLE_RATE = ConfigParam(env_vars=['LOGFIRE_TRACE_SAMPLE_RATE', 'OTEL_TRACES_SAMPLER_ARG'], allow_file_config=True, default=1.0, tp=float)
9696
"""Head sampling rate for traces."""

logfire/_internal/db_statement_summary.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import annotations
22

33
import re
4-
from typing import Any, Mapping
4+
from collections.abc import Mapping
5+
from typing import Any
56

67
MAX_QUERY_MESSAGE_LENGTH = 80
78

logfire/_internal/exporters/console.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import json
99
import os
1010
import sys
11-
from collections.abc import Sequence
11+
from collections.abc import Mapping, Sequence
1212
from dataclasses import dataclass
1313
from datetime import datetime, timezone
1414
from textwrap import indent as indent_text
15-
from typing import Any, List, Literal, Mapping, TextIO, Tuple, cast
15+
from typing import Any, Literal, TextIO, cast
1616

1717
from opentelemetry.sdk._logs import LogData, LogRecord
1818
from opentelemetry.sdk._logs.export import LogExporter, LogExportResult
@@ -46,7 +46,7 @@
4646

4747
# A list of (text, style) pairs that can be passed to rich's `Text.assemble`.
4848
# When logging without colors, just the text is used in a plain `print`.
49-
TextParts = List[Tuple[str, str]]
49+
TextParts = list[tuple[str, str]]
5050

5151

5252
@dataclass

0 commit comments

Comments
 (0)