From 55068b82dcb47a6489dbf4da5e96a9da63e4f805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez-Mondrag=C3=B3n?= Date: Tue, 3 Sep 2024 22:49:59 -0600 Subject: [PATCH] refactor(templates): Drop support for Python 3.8 in templates --- .../{{cookiecutter.mapper_id}}/pyproject.toml | 3 +-- .../{{cookiecutter.tap_id}}/pyproject.toml | 3 +-- .../{{cookiecutter.library_name}}/rest-client.py | 13 ++++--------- .../{{cookiecutter.library_name}}/streams.py | 10 ++-------- .../{{cookiecutter.target_id}}/pyproject.toml | 3 +-- samples/sample_tap_dummy_json/pyproject.toml | 9 ++++----- 6 files changed, 13 insertions(+), 28 deletions(-) diff --git a/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml b/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml index b397face44..4e398b1d87 100644 --- a/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml +++ b/cookiecutter/mapper-template/{{cookiecutter.mapper_id}}/pyproject.toml @@ -16,7 +16,6 @@ keywords = [ classifiers = [ "Intended Audience :: Developers", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -30,7 +29,7 @@ packages = [ {%- endif %} [tool.poetry.dependencies] -python = ">=3.8" +python = ">=3.9" singer-sdk = { version="~=0.40.0"{{ ', extras = ["faker"]' if cookiecutter.faker_extra }} } fs-s3fs = { version = "~=1.1.1", optional = true } diff --git a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml index 3037bcabff..04f672f9fa 100644 --- a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml +++ b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/pyproject.toml @@ -15,7 +15,6 @@ keywords = [ classifiers = [ "Intended Audience :: Developers", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -29,7 +28,7 @@ packages = [ {%- endif %} [tool.poetry.dependencies] -python = ">=3.8" +python = ">=3.9" importlib-resources = { version = "==6.4.*", python = "<3.9" } singer-sdk = { version="~=0.40.0", extras = [ {%- if cookiecutter.auth_method == "JWT" -%}"jwt", {% endif -%} diff --git a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/{{cookiecutter.library_name}}/rest-client.py b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/{{cookiecutter.library_name}}/rest-client.py index fb805ad555..3f2c784f6d 100644 --- a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/{{cookiecutter.library_name}}/rest-client.py +++ b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/{{cookiecutter.library_name}}/rest-client.py @@ -2,10 +2,10 @@ from __future__ import annotations -import sys -{%- if cookiecutter.auth_method in ("OAuth2", "JWT") %} +{% if cookiecutter.auth_method in ("OAuth2", "JWT") -%} from functools import cached_property -{%- endif %} +{% endif -%} +from importlib import resources from typing import TYPE_CHECKING, Any, Iterable {% if cookiecutter.auth_method == "API Key" -%} @@ -40,11 +40,6 @@ {% endif -%} -if sys.version_info >= (3, 9): - import importlib.resources as importlib_resources -else: - import importlib_resources - if TYPE_CHECKING: import requests {%- if cookiecutter.auth_method in ("OAuth2", "JWT") %} @@ -55,7 +50,7 @@ # TODO: Delete this is if not using json files for schema definition -SCHEMAS_DIR = importlib_resources.files(__package__) / "schemas" +SCHEMAS_DIR = resources.files(__package__) / "schemas" class {{ cookiecutter.source_name }}Stream({{ cookiecutter.stream_type }}Stream): diff --git a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/{{cookiecutter.library_name}}/streams.py b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/{{cookiecutter.library_name}}/streams.py index 69c955e6f3..6e296a2594 100644 --- a/cookiecutter/tap-template/{{cookiecutter.tap_id}}/{{cookiecutter.library_name}}/streams.py +++ b/cookiecutter/tap-template/{{cookiecutter.tap_id}}/{{cookiecutter.library_name}}/streams.py @@ -2,21 +2,15 @@ from __future__ import annotations -import sys import typing as t +from importlib import resources from singer_sdk import typing as th # JSON Schema typing helpers from {{ cookiecutter.library_name }}.client import {{ cookiecutter.source_name }}Stream -if sys.version_info >= (3, 9): - import importlib.resources as importlib_resources -else: - import importlib_resources - - # TODO: Delete this is if not using json files for schema definition -SCHEMAS_DIR = importlib_resources.files(__package__) / "schemas" +SCHEMAS_DIR = resources.files(__package__) / "schemas" {%- if cookiecutter.stream_type == "GraphQL" %} diff --git a/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml b/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml index 42d71ae998..299094d390 100644 --- a/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml +++ b/cookiecutter/target-template/{{cookiecutter.target_id}}/pyproject.toml @@ -15,7 +15,6 @@ keywords = [ classifiers = [ "Intended Audience :: Developers", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -29,7 +28,7 @@ packages = [ {%- endif %} [tool.poetry.dependencies] -python = ">=3.8" +python = ">=3.9" singer-sdk = { version="~=0.40.0"{{ ', extras = ["faker"]' if cookiecutter.faker_extra }} } fs-s3fs = { version = "~=1.1.1", optional = true } {%- if cookiecutter.serialization_method != "SQL" %} diff --git a/samples/sample_tap_dummy_json/pyproject.toml b/samples/sample_tap_dummy_json/pyproject.toml index 1263b3ca4e..c723477481 100644 --- a/samples/sample_tap_dummy_json/pyproject.toml +++ b/samples/sample_tap_dummy_json/pyproject.toml @@ -11,7 +11,6 @@ keywords = [ classifiers = [ "Intended Audience :: Developers", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -20,13 +19,13 @@ classifiers = [ license = "Apache-2.0" [tool.poetry.dependencies] -python = ">=3.8" +python = ">=3.9" requests = "~=2.32.3" -singer-sdk = { version="~=0.38.0", extras = [] } +singer-sdk = {path = "../..", develop = true} [tool.poetry.group.dev.dependencies] pytest = ">=8" -singer-sdk = { version="~=0.38.0", extras = ["testing"] } +singer-sdk = {path = "../..", develop = true, extras = ["testing"]} [tool.poetry.extras] s3 = ["fs-s3fs"] @@ -36,7 +35,7 @@ python_version = "3.12" warn_unused_configs = true [build-system] -requires = ["poetry-core==1.9.0"] +requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.poetry.scripts]