Skip to content

Commit

Permalink
Drop support for Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Sep 28, 2024
1 parent 051a7fe commit 526637f
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ Estimated cost: $0.01
Click to unfold installation
</summary>

pypinfo is distributed on **PyPI** as a universal wheel and is available on Linux/macOS and Windows and supports Python 3.7+.
pypinfo is distributed on **PyPI** as a universal wheel and is available on Linux, macOS and Windows.

This is relatively painless, I swear.

Expand Down
3 changes: 1 addition & 2 deletions pypinfo/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from decimal import ROUND_UP, Decimal
from typing import List

import click
from binary import TEBIBYTE, convert_units
Expand Down Expand Up @@ -102,7 +101,7 @@
def pypinfo(
ctx: click.Context,
project: str,
fields: List[str],
fields: list[str],
auth: str,
run: bool,
json: bool,
Expand Down
21 changes: 11 additions & 10 deletions pypinfo/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import json
import os
from datetime import date, datetime
from typing import Any, Dict, Iterable, List, Optional, Tuple
from typing import Any, Optional
from collections.abc import Iterable

from google.cloud.bigquery import Client
from google.cloud.bigquery.job import QueryJobConfig
Expand All @@ -22,7 +23,7 @@
END_DATE = '-1'
DEFAULT_LIMIT = 10

Rows = List[List[str]]
Rows = list[list[str]]


def create_config() -> QueryJobConfig:
Expand All @@ -31,7 +32,7 @@ def create_config() -> QueryJobConfig:
return config


def normalize_dates(start_date: str, end_date: str) -> Tuple[str, str]:
def normalize_dates(start_date: str, end_date: str) -> tuple[str, str]:
"""If a date is yyyy-mm, normalize as first or last yyyy-mm-dd of the month.
Otherwise, return unchanged.
"""
Expand Down Expand Up @@ -85,7 +86,7 @@ def format_date(date: str, timestamp_format: str) -> str:
return date


def month_ends(yyyy_mm: str) -> Tuple[str, str]:
def month_ends(yyyy_mm: str) -> tuple[str, str]:
"""Helper to return start_date and end_date of a month as yyyy-mm-dd"""
year, month = map(int, yyyy_mm.split("-"))
first = date(year, month, 1)
Expand All @@ -94,7 +95,7 @@ def month_ends(yyyy_mm: str) -> Tuple[str, str]:
return str(first), str(last)


def strip_trailing_zero(release: Tuple[int, ...]) -> Tuple[int, ...]:
def strip_trailing_zero(release: tuple[int, ...]) -> tuple[int, ...]:
"""Helper to strip trailing 0 in a tuple of integers"""
new_len = len(release)
while new_len > 1 and release[new_len - 1] == 0:
Expand Down Expand Up @@ -271,7 +272,7 @@ def add_percentages(rows: Rows, include_sign: bool = True) -> Rows:
return rows


def get_download_total(rows: Rows) -> Tuple[int, int]:
def get_download_total(rows: Rows) -> tuple[int, int]:
"""Return the total downloads, and the downloads column"""
headers = rows.pop(0)
index = headers.index('download_count')
Expand Down Expand Up @@ -341,13 +342,13 @@ def tabulate(rows: Rows, markdown: bool = False) -> str:
return tabulated


def format_json(rows: Rows, query_info: Dict[str, Any], indent: Optional[int]) -> str:
def format_json(rows: Rows, query_info: dict[str, Any], indent: Optional[int]) -> str:
headers, *_data = rows
data: List[Any] = _data
items: List[Dict[str, Any]] = []
data: list[Any] = _data
items: list[dict[str, Any]] = []

for d in data:
item: Dict[str, Any] = {}
item: dict[str, Any] = {}
for i in range(len(headers)):
if d[i].isdigit():
d[i] = int(d[i])
Expand Down
3 changes: 2 additions & 1 deletion pypinfo/db.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import contextlib
import os
from typing import Iterator, Optional
from typing import Optional
from collections.abc import Iterator

from platformdirs import user_data_dir
from tinydb import TinyDB, Query, where
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "pypinfo"
description = "View PyPI download statistics with ease."
readme = "README.md"
license = "MIT"
requires-python = ">=3.8"
requires-python = ">=3.9"
keywords = [
"bigquery",
"downloads",
Expand All @@ -27,7 +27,6 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
11 changes: 6 additions & 5 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from freezegun import freeze_time
from typing import Any, Iterator, List, Tuple
from typing import Any
from collections.abc import Iterator
import copy
import pytest
import re
Expand Down Expand Up @@ -172,7 +173,7 @@ def test_build_query() -> None:
def test_build_query_specifier() -> None:
# pypinfo -sd -2 -ed -1 -l 20 --test 'foo==1'
project = "foo==1"
all_fields: List[Field] = []
all_fields: list[Field] = []
start_date = "-2"
end_date = "-1"
days = None
Expand Down Expand Up @@ -273,7 +274,7 @@ def test_build_query_where() -> None:
def test_build_query_no_project() -> None:
# pypinfo -sd -2 -ed -1 -l 20 --all --test ''
project = ""
all_fields: List[Field] = []
all_fields: list[Field] = []
start_date = "-2"
end_date = "-1"
days = None
Expand Down Expand Up @@ -508,7 +509,7 @@ def test_format_json() -> None:


def test_parse_query_result() -> None:
data: List[Tuple[Any, ...]] = [
data: list[tuple[Any, ...]] = [
("name", "other"),
("name1", 1),
("name2", 2),
Expand All @@ -523,7 +524,7 @@ class MockRowIterator(RowIterator): # type: ignore[misc]
def __init__(self) -> None:
super().__init__(None, None, None, schema)

def __iter__(self) -> Iterator[Tuple[Any, ...]]:
def __iter__(self) -> Iterator[tuple[Any, ...]]:
return iter(data[1:])

actual = core.parse_query_result(MockRowIterator())
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[tox]
minversion = 1.9
envlist =
py38,
py39,
py310,
py311,
Expand Down

0 comments on commit 526637f

Please sign in to comment.