Skip to content

Commit

Permalink
refactor: Dropped support for Python 3.8 (#335)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored Jan 3, 2025
1 parent 930a431 commit 9ec93f1
Show file tree
Hide file tree
Showing 14 changed files with 393 additions and 318 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test_tap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
- "3.11"
- "3.10"
- "3.9"
- "3.8"
# run the matrix jobs one after the other so they can benefit from caching
max-parallel: 1

Expand Down
2 changes: 1 addition & 1 deletion .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sonar.python.version=3.7, 3.8, 3.9, 3.10
sonar.python.version=3.9, 3.10, 3.11, 3.12, 3.13
sonar.cpd.exclusions=**/*
276 changes: 124 additions & 152 deletions poetry.lock

Large diffs are not rendered by default.

25 changes: 14 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -28,7 +27,7 @@ classifiers = [
beautifulsoup4 = "~=4.12.0"
nested-lookup = "~=0.2.25"
PyJWT = "2.9.0"
python = ">=3.8"
python = ">=3.9"
python-dateutil = "~=2.9"
requests = "~=2.32.3"
# For local SDK dev:
Expand Down Expand Up @@ -62,17 +61,21 @@ markers = [
]

[tool.ruff]
target-version = "py38"
target-version = "py39"

[tool.ruff.lint]
ignore = []
select = [
"F", # Pyflakes
"E", # pycodestyle (errors)
"W", # pycodestyle (warnings)
"I", # isort
"UP", # pyupgrade
"FA", # flake8-future-annotations
"SIM", # flake8-simplify
"RUF", # Ruff-specific rules
"F", # Pyflakes
"E", # pycodestyle (errors)
"W", # pycodestyle (warnings)
"I", # isort
"UP", # pyupgrade
"DTZ", # flake8-datetimez
"FA", # flake8-future-annotations
"SIM", # flake8-simplify
"TC", # flake8-type-checking
"PERF", # Perflint
"FURB", # refurb
"RUF", # Ruff-specific rules
]
8 changes: 5 additions & 3 deletions tap_github/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
from datetime import datetime, timedelta, timezone
from os import environ
from random import choice, shuffle
from typing import Any
from typing import TYPE_CHECKING, Any

import jwt
import requests
from singer_sdk.authenticators import APIAuthenticatorBase
from singer_sdk.streams import RESTStream

if TYPE_CHECKING:
from singer_sdk.streams import RESTStream


class TokenManager:
Expand Down Expand Up @@ -307,7 +309,7 @@ def prepare_tokens(self) -> list[TokenManager]:
)
if app_token_manager.is_valid_token():
app_token_managers.append(app_token_manager)
except ValueError as e:
except ValueError as e: # noqa: PERF203
self.logger.warning(
f"An error was thrown while preparing an app token: {e}"
)
Expand Down
10 changes: 7 additions & 3 deletions tap_github/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
import random
import time
from types import FrameType
from typing import Any, ClassVar, Iterable, cast
from typing import TYPE_CHECKING, Any, ClassVar, cast
from urllib.parse import parse_qs, urlparse

import requests
from backoff.types import Details
from dateutil.parser import parse
from nested_lookup import nested_lookup
from singer_sdk.exceptions import FatalAPIError, RetriableAPIError
Expand All @@ -20,6 +18,12 @@

from tap_github.authenticator import GitHubTokenAuthenticator

if TYPE_CHECKING:
from collections.abc import Iterable

import requests
from backoff.types import Details

EMPTY_REPO_ERROR_STATUS = 409


Expand Down
5 changes: 4 additions & 1 deletion tap_github/organization_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

from __future__ import annotations

from typing import Any, ClassVar, Iterable
from typing import TYPE_CHECKING, Any, ClassVar

from singer_sdk import typing as th # JSON Schema typing helpers

from tap_github.client import GitHubRestStream

if TYPE_CHECKING:
from collections.abc import Iterable


class OrganizationStream(GitHubRestStream):
"""Defines a GitHub Organization Stream.
Expand Down
8 changes: 6 additions & 2 deletions tap_github/repository_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

from __future__ import annotations

from typing import Any, ClassVar, Iterable
from typing import TYPE_CHECKING, Any, ClassVar
from urllib.parse import parse_qs, urlparse

import requests
from dateutil.parser import parse
from singer_sdk import typing as th # JSON Schema typing helpers
from singer_sdk.exceptions import FatalAPIError
Expand All @@ -21,6 +20,11 @@
)
from tap_github.scraping import scrape_dependents, scrape_metrics

if TYPE_CHECKING:
from collections.abc import Iterable

import requests


class RepositoryStream(GitHubRestStream):
"""Defines 'Repository' stream."""
Expand Down
15 changes: 7 additions & 8 deletions tap_github/scraping.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
import re
import time
from datetime import datetime, timezone
from typing import Any, Iterable, cast
from typing import TYPE_CHECKING, Any, cast
from urllib.parse import urlparse

import requests
from bs4 import NavigableString, Tag

if TYPE_CHECKING:
from collections.abc import Iterable

from bs4 import NavigableString, Tag

used_by_regex = re.compile(" {3}Used by ")
contributors_regex = re.compile(" {3}Contributors ")
Expand All @@ -30,12 +34,7 @@ def scrape_dependents(
# Navigate through Package toggle if present
base_url = urlparse(response.url).hostname or "github.com"
options = soup.find_all("a", class_="select-menu-item")
links = []
if len(options) > 0:
for link in options:
links.append(link["href"])
else:
links.append(response.url)
links = [link["href"] for link in options] if len(options) > 0 else [response.url]

logger.debug(links)

Expand Down
6 changes: 4 additions & 2 deletions tap_github/streams.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations

from enum import Enum

from singer_sdk.streams.core import Stream
from typing import TYPE_CHECKING

from tap_github.organization_streams import (
OrganizationStream,
Expand Down Expand Up @@ -52,6 +51,9 @@
)
from tap_github.user_streams import StarredStream, UserContributedToStream, UserStream

if TYPE_CHECKING:
from singer_sdk.streams.core import Stream


class Streams(Enum):
"""
Expand Down
Loading

0 comments on commit 9ec93f1

Please sign in to comment.