Skip to content

Commit

Permalink
Merge pull request #50 from avaldebe/drop-py37
Browse files Browse the repository at this point in the history
drop Python 3.7 support and enforce Python 3.8+ codding standards
  • Loading branch information
avaldebe authored Jun 26, 2024
2 parents 17e0f5e + 1b14dc9 commit 6043d71
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
prerelease: [false]
include:
- python: '3.13'
Expand Down
13 changes: 4 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
repos:
- repo: https://github.com/psf/black
rev: "22.3.0"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9
hooks:
- id: black
args: [-l, "80"]
- id: ruff-format # formatter
- id: ruff # linter
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
exclude: '(docs/.*)|(setup\.py)'
additional_dependencies: [types-aiofiles, types-requests]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
[![CI/CD](https://github.com/JohnPaton/airbase/actions/workflows/cicd.yaml/badge.svg?branch=master)](https://github.com/JohnPaton/airbase/actions/workflows/cicd.yaml)
[![Documentation Status](https://readthedocs.org/projects/airbase/badge/?version=latest)](https://airbase.readthedocs.io/en/latest/?badge=latest)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Code style: Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/format.json)](https://github.com/astral-sh/ruff)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)

# 🌬 AirBase

Expand Down
7 changes: 1 addition & 6 deletions airbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
from __future__ import annotations

import sys

if sys.version_info >= (3, 8): # pragma: no cover
from importlib import metadata
else: # pragma: no cover
import importlib_metadata as metadata
from importlib import metadata

__version__: str | None
try:
Expand Down
14 changes: 4 additions & 10 deletions airbase/airbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
import warnings
from datetime import datetime
from pathlib import Path

if sys.version_info >= (3, 8): # pragma: no cover
from typing import TypedDict
else: # pragma: no cover
from typing_extensions import TypedDict
from typing import TypedDict

from .fetch import (
fetch_text,
Expand Down Expand Up @@ -158,8 +154,8 @@ def request(

if shortpl is not None:
warnings.warn(
f"the shortpl option has been deprecated and will be removed on v1. "
f"Use client.request([client._pollutants_ids[p] for p in shortpl], ...) instead.",
"the shortpl option has been deprecated and will be removed on v1. "
"Use client.request([client._pollutants_ids[p] for p in shortpl], ...) instead.",
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -334,9 +330,7 @@ def _get_csv_links(self, force: bool = False) -> None:

if self.verbose:
print(
"Generated {:,} CSV links ready for downloading".format(
len(self._csv_links)
),
f"Generated {len(self._csv_links):,} CSV links ready for downloading",
file=sys.stderr,
)

Expand Down
1 change: 1 addition & 0 deletions airbase/resources.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Global variables for URL templating"""

import datetime

E1A_SUMMARY_URL = "http://discomap.eea.europa.eu/map/fme/E1a/summaryE1a.js"
Expand Down
27 changes: 17 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,25 @@ skip_covered = true
skip_empty = true
show_missing = true

[tool.black]
[tool.ruff]
target-version = "py38"
line-length = 80
target-version = ["py37"]
extend-exclude = ["docs", "scripts", "build"]

[tool.isort]
line_length = 80
py_version = "37"
profile = "black"
src_paths = ["airbase", "tests"]
extend_skip = ["scripts"]
[tool.ruff.lint]
select = ["E", "W", "F", "I", "UP"]
ignore = [
"E501", # https://docs.astral.sh/ruff/rules/line-too-long/
]

[tool.ruff.lint.per-file-ignores]
"cli.py" = [ # typer needs typing.Optional and typing.List
"UP006", # https://docs.astral.sh/ruff/rules/non-pep585-annotation/
"UP007", # https://docs.astral.sh/ruff/rules/non-pep604-annotation/
]

[tool.mypy]
python_version = "3.8"
warn_unused_configs = true
warn_unused_ignores = false
warn_no_return = true
Expand All @@ -41,7 +48,7 @@ warn_unreachable = true
show_error_codes = true
pretty = true
sqlite_cache = true
exclude = "docs|scripts"
exclude = "docs|scripts|build"

[[tool.mypy.overrides]]
module = ["tqdm"]
Expand All @@ -50,7 +57,7 @@ ignore_missing_imports = true
[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py37, py38, py39, py310, py311, py312, lint, docs, integration
envlist = py38, py39, py310, py311, py312, lint, docs, integration
skip_missing_interpreters = True
isolated_build = True
Expand Down
4 changes: 1 addition & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ classifiers =
License :: OSI Approved :: MIT License
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Expand All @@ -21,14 +20,13 @@ classifiers =
Topic :: Scientific/Engineering :: Atmospheric Science

[options]
python_requires = >=3.7,<4
python_requires = >=3.8,<4
install_requires =
aiohttp; python_version < "3.12"
aiohttp >= 3.9.0; python_version >= "3.12"
aiofiles
importlib_resources; python_version < "3.11"
tqdm
typing_extensions; python_version < "3.8"
typer >=0.9.1
packages = find:
include_package_data = True
Expand Down
2 changes: 1 addition & 1 deletion tests/test_airbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_download_file(self, tmp_path: Path):
assert header == header_expected

# make sure header only there once
is_header = (l.strip() == header_expected for l in lines)
is_header = (line.strip() == header_expected for line in lines)
assert sum(is_header) == 1

def test_download_metadata(self, tmp_path: Path):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ def test_fetch_to_file(tmp_path: Path, csv_urls: dict[str, str]):
assert path.exists()

# drop the header and compare data rows
rows = lambda text: text.splitlines()[1:]
def rows(text: str) -> list[str]:
return text.splitlines()[1:]

data_on_file = rows(path.read_text())
data_rows = list(
itertools.chain.from_iterable(rows(text) for text in csv_urls.values())
Expand Down

0 comments on commit 6043d71

Please sign in to comment.