Skip to content

Commit 979b212

Browse files
chore: Dropped support for Python 3.8 (#196)
1 parent 75b1df8 commit 979b212

File tree

10 files changed

+1051
-571
lines changed

10 files changed

+1051
-571
lines changed

.github/workflows/ci_workflow.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ on:
2323
- tox.ini
2424
workflow_dispatch:
2525

26+
env:
27+
FORCE_COLOR: 1
28+
2629
jobs:
2730
pytest:
28-
runs-on: ubuntu-latest
29-
env:
30-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
31+
runs-on: ubuntu-24.04
3132
strategy:
3233
fail-fast: false
3334
matrix:
3435
python-version:
35-
- "3.8"
3636
- "3.9"
3737
- "3.10"
3838
- "3.11"

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,10 @@ repos:
3232
exclude: 'tests'
3333
additional_dependencies:
3434
- types-pytz==2022.7.1.2
35+
36+
- repo: https://github.com/python-jsonschema/check-jsonschema
37+
rev: 0.33.0
38+
hooks:
39+
- id: check-dependabot
40+
- id: check-github-workflows
41+
- id: check-meltano

meltano.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ plugins:
2121
loaders:
2222
- name: target-csv
2323
namespace: target_csv
24-
executable: ./target-csv.sh
24+
pip_url: -e .
2525
capabilities:
26-
- state
27-
- catalog
28-
- discover
26+
- about
27+
- stream-maps
28+
- schema-flattening
2929
settings:
3030
- name: output_path
3131
kind: string

poetry.lock

Lines changed: 997 additions & 522 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ classifiers = [
1616
"Intended Audience :: Developers",
1717
"License :: OSI Approved :: Apache Software License",
1818
"Operating System :: OS Independent",
19-
"Programming Language :: Python :: 3.8",
2019
"Programming Language :: Python :: 3.9",
2120
"Programming Language :: Python :: 3.10",
2221
"Programming Language :: Python :: 3.11",
@@ -41,7 +40,7 @@ build-backend = "poetry.core.masonry.api"
4140

4241
[tool.ruff]
4342
line-length = 88
44-
target-version = "py38"
43+
target-version = "py39"
4544

4645
[tool.ruff.lint]
4746
ignore = [
@@ -53,8 +52,14 @@ select = [
5352
"D", # pydocstyle
5453
"E", # pycodestyle (error)
5554
"F", # pyflakes
56-
"W", # pycodestyle (warning)
55+
"FA", # flake8-future-annotations
56+
"FURB", # refurb
57+
"PERF", # Perflint
58+
"UP", # pyupgrade
5759
"S", # flake8-bandit
60+
"SIM", # flake8-simplify
61+
"TC", # flake8-type-checking
62+
"W", # pycodestyle (warning)
5863
]
5964

6065
[tool.ruff.lint.flake8-annotations]

target-csv.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

target_csv/serialization.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
import csv # noqa: D100
66
import tempfile
7-
from pathlib import Path
8-
from typing import Any
7+
from typing import Any, TYPE_CHECKING
8+
9+
if TYPE_CHECKING:
10+
from pathlib import Path
911

1012

1113
def write_csv(

target_csv/sinks.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,30 @@
77
import sys
88
import warnings
99
from pathlib import Path
10-
from typing import Any, Dict, List, Optional
10+
from typing import Any, TYPE_CHECKING
1111

1212
import pytz
13-
from singer_sdk import Target
1413
from singer_sdk.sinks import BatchSink
1514

1615
from target_csv.serialization import write_batch, write_header
1716

17+
if TYPE_CHECKING:
18+
from singer_sdk import Target
19+
1820

1921
class CSVSink(BatchSink):
2022
"""CSV target sink class."""
2123

22-
max_size = sys.maxsize # We want all records in one batch
24+
MAX_SIZE_DEFAULT = sys.maxsize
2325

2426
def __init__( # noqa: D107
2527
self,
2628
target: Target,
2729
stream_name: str,
28-
schema: Dict,
29-
key_properties: Optional[List[str]],
30+
schema: dict,
31+
key_properties: list[str] | None,
3032
) -> None:
31-
self._timestamp_time: Optional[datetime.datetime] = None
33+
self._timestamp_time: datetime.datetime | None = None
3234
super().__init__(target, stream_name, schema, key_properties)
3335

3436
@property
@@ -41,7 +43,7 @@ def timestamp_time(self) -> datetime.datetime: # noqa: D102
4143
return self._timestamp_time
4244

4345
@property
44-
def filepath_replacement_map(self) -> Dict[str, str]: # noqa: D102
46+
def filepath_replacement_map(self) -> dict[str, str]: # noqa: D102
4547
return {
4648
"stream_name": self.stream_name,
4749
"datestamp": self.timestamp_time.strftime(self.config["datestamp_format"]),
@@ -113,7 +115,7 @@ def process_batch(self, context: dict) -> None:
113115
self.logger.warning("No values in %s records collection.", self.stream_name)
114116
context["records"] = []
115117

116-
records: List[Dict[str, Any]] = context["records"]
118+
records: list[dict[str, Any]] = context["records"]
117119
if "record_sort_property_name" in self.config:
118120
sort_property_name = self.config["record_sort_property_name"]
119121
records = sorted(records, key=lambda x: x[sort_property_name])

tests/test_core.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
"""Tests standard target features using the built-in SDK tests library."""
22

3-
from pathlib import Path
4-
import sys
5-
from typing import Any, Dict
3+
from __future__ import annotations
4+
5+
from typing import Any, TYPE_CHECKING
66

77
from singer_sdk.testing import get_target_test_class
88
from singer_sdk.testing.suites import TestSuite
99
from singer_sdk.testing.templates import TargetFileTestTemplate
1010

11-
from . import data_files
1211
from target_csv.target import TargetCSV
1312

14-
if sys.version_info >= (3, 9):
15-
from importlib.resources import files
16-
else:
17-
from importlib_resources import files
13+
from . import data_files
14+
15+
from importlib.resources import files
16+
17+
if TYPE_CHECKING:
18+
from importlib.abc import Traversable
1819

19-
SAMPLE_CONFIG: Dict[str, Any] = {
20+
SAMPLE_CONFIG: dict[str, Any] = {
2021
"escape_character": "\\",
2122
}
2223

@@ -25,7 +26,7 @@ class MultipleStreamsTest(TargetFileTestTemplate):
2526
name = "users_and_employees"
2627

2728
@property
28-
def singer_filepath(self) -> Path:
29+
def singer_filepath(self) -> Traversable:
2930
return files(data_files) / f"{self.name}.singer"
3031

3132

tests/test_csv.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
"""CSV-related tests."""
22

3+
from __future__ import annotations
4+
35
from pathlib import Path
4-
from typing import Any, Dict, List, Tuple
6+
from typing import Any
57

68
import pytest
79

810
from target_csv.serialization import read_csv, write_batch, write_header
911

10-
SAMPLE_DATASETS: List[Tuple[Dict, List[Dict[str, Any]]]] = [
12+
SAMPLE_DATASETS: list[tuple[dict, list[dict[str, Any]]]] = [
1113
(
1214
# JSON Schema
1315
{
@@ -59,7 +61,7 @@ def output_filepath(output_dir) -> Path:
5961

6062

6163
@pytest.fixture
62-
def test_file_paths(output_dir) -> List[Path]:
64+
def test_file_paths(output_dir) -> list[Path]:
6365
paths = []
6466
for dir in range(4):
6567
path = Path(output_dir / f"test-dir-{dir}/csv-test-output-{dir}.csv")
@@ -90,6 +92,6 @@ def test_csv_roundtrip(output_filepath) -> None:
9092
write_batch(filepath=output_filepath, records=records, keys=keys)
9193
read_records = read_csv(filepath=output_filepath)
9294
for orig_record, new_record in zip(records, read_records):
93-
for key in orig_record.keys():
95+
for key in orig_record:
9496
# Note: Results are stringified during serialization
9597
assert str(orig_record[key]) == new_record[key]

0 commit comments

Comments
 (0)