Skip to content

Commit

Permalink
Py 3.10 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
devdupont committed May 27, 2024
1 parent d95b64a commit 5e18158
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 1,468 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/python-hatch-env
Expand Down
28 changes: 0 additions & 28 deletions .pre-commit-config.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions .pylintrc

This file was deleted.

4 changes: 3 additions & 1 deletion avwx/forecast/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
from __future__ import annotations

from datetime import datetime, timedelta, timezone
from typing import TYPE_CHECKING, Callable
from typing import TYPE_CHECKING

# module
from avwx.base import ManagedReport
from avwx.parsing import core
from avwx.structs import Code, Number, ReportData, Timestamp

if TYPE_CHECKING:
from collections.abc import Callable

from avwx.service import Service


Expand Down
9 changes: 5 additions & 4 deletions avwx/forecast/nbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@

# Reference: https://www.weather.gov/mdl/nbm_textcard_v32

# pylint: disable=too-many-arguments

# stdlib
from __future__ import annotations

from contextlib import suppress
from typing import Callable
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Callable

try:
from typing import TypeAlias
except ImportError:
from typing_extensions import TypeAlias
from typing import TypeAlias

# module
from avwx import structs
Expand Down
4 changes: 2 additions & 2 deletions avwx/load_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

import json
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from collections.abc import ItemsView, Iterator, ValuesView
from collections.abc import Callable, ItemsView, Iterator, ValuesView


class LazyLoad:
Expand Down
2 changes: 1 addition & 1 deletion avwx/parsing/sanitization/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Core sanitiation functions that accept report-specific elements."""

from typing import Callable
from collections.abc import Callable

from avwx.parsing.core import dedupe, is_variable_wind_direction, is_wind
from avwx.parsing.sanitization.cleaners.base import (
Expand Down
2 changes: 1 addition & 1 deletion avwx/station/station.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def _query_coords(lat: float, lon: float, n: int, d: float) -> list[tuple[str, f
if n == 1:
dist, index = [dist], [index]
# NOTE: index == len of list means Tree ran out of items
return [(_COORDS.value[i][0], d) for i, d in zip(index, dist) if i < len(_COORDS.value)]
return [(_COORDS.value[i][0], d) for i, d in zip(index, dist, strict=True) if i < len(_COORDS.value)]


def station_filter(station: Station, *, is_airport: bool, reporting: bool) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion avwx/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,6 @@ def log(self, item: str, replacement: str | None = None) -> None:

def log_list(self, before: list[str], after: list[str]) -> None:
"""Log list differences. Assumes that list length and order haven't changed."""
for item, replacement in zip(before, after):
for item, replacement in zip(before, after, strict=True):
if item != replacement:
self.log(item, replacement)
2 changes: 1 addition & 1 deletion docs/launch.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pull request on [GitHub](https://github.com/avwx-rest/avwx-engine)

# Installation

AVWX is available on PyPI and requires Python 3.9 and above. Note: the package
AVWX is available on PyPI and requires Python 3.10 and above. Note: the package
name is ``avwx-engine``, but the import is ``avwx``

```bash
Expand Down
1,399 changes: 0 additions & 1,399 deletions poetry.lock

This file was deleted.

2 changes: 0 additions & 2 deletions poetry.toml

This file was deleted.

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 = "avwx-engine"
version = "1.8.28"
description = "Aviation weather report parsing library"
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
license = "MIT"
keywords = ["aviation", "weather", "metar"]
authors = [
Expand All @@ -20,7 +20,6 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down
10 changes: 5 additions & 5 deletions tests/current/test_airsigmet.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def test_coords_from_text(report: str, coords: tuple[tuple], start: int, extra:
ret_report, ret_coords, ret_start = airsigmet._coords_from_text(report, -1)
assert ret_report == extra
assert ret_start == start
for coord, (lat, lon) in zip(ret_coords, coords):
for coord, (lat, lon) in zip(ret_coords, coords, strict=True):
assert coord.lat == lat
assert coord.lon == lon

Expand All @@ -378,7 +378,7 @@ def test_coords_from_navaids(report: str, coords: tuple[tuple], start: int, extr
ret_report, ret_coords, ret_start = airsigmet._coords_from_navaids(report, -1)
assert ret_report == extra
assert ret_start == start
for coord, (lat, lon) in zip(ret_coords, coords):
for coord, (lat, lon) in zip(ret_coords, coords, strict=True):
assert round(coord.lat, 2) == lat
assert round(coord.lon, 2) == lon

Expand Down Expand Up @@ -423,7 +423,7 @@ def test_bounds(wx: str, coords: tuple[tuple], bounds: list[str], extra: str) ->
ret_wx, ret_coords, ret_bounds = airsigmet._bounds(wx.split())
assert ret_wx == extra.split()
assert ret_bounds == bounds
for coord, (lat, lon) in zip(ret_coords, coords):
for coord, (lat, lon) in zip(ret_coords, coords, strict=True):
assert round(coord.lat, 2) == lat
assert round(coord.lon, 2) == lon

Expand Down Expand Up @@ -525,7 +525,7 @@ def test_parse() -> None:
def test_contains(lat: int, lon: int, results: tuple) -> None:
"""Test if report contains a coordinate."""
coord = Coord(lat, lon)
for report, result in zip(COORD_REPORTS, results):
for report, result in zip(COORD_REPORTS, results, strict=True):
assert report.contains(coord) == result


Expand All @@ -541,7 +541,7 @@ def test_contains(lat: int, lon: int, results: tuple) -> None:
def test_intersects(coords: tuple, results: tuple) -> None:
"""Test if report intersects a path."""
path = LineString(coords)
for report, result in zip(COORD_REPORTS, results):
for report, result in zip(COORD_REPORTS, results, strict=True):
assert report.intersects(path) == result


Expand Down
2 changes: 1 addition & 1 deletion tests/current/test_metar.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def test_parse_runway_visibility(
else:
assert_number(rvr.visibility, *vis)
if var:
for original, items in zip(rvr.variable_visibility, var):
for original, items in zip(rvr.variable_visibility, var, strict=True):
assert_number(original, *items)
assert rvr.trend == trend

Expand Down
2 changes: 1 addition & 1 deletion tests/current/test_notam.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,5 +348,5 @@ def test_notam_e2e(ref: dict, icao: str, unused: Any) -> None: # noqa: ARG001
reports = [report["data"]["raw"] for report in ref["reports"]]
assert station.parse(reports) is True
assert isinstance(station.last_updated, datetime)
for parsed, report in zip(station.data, ref["reports"]):
for parsed, report in zip(station.data, ref["reports"], strict=True):
assert asdict(parsed) == report["data"]
4 changes: 2 additions & 2 deletions tests/current/test_pirep.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def test_wx(text: str, wx: list[tuple[str, str]], vis: int | None, remain: list[
wx_codes, flight_visibility, other = pirep._wx(text)
assert isinstance(wx_codes, list)
assert other == remain
for item, code in zip(wx, wx_codes):
for item, code in zip(wx, wx_codes, strict=True):
assert Code(item[0], item[1]) == code
assert_value(flight_visibility, vis)

Expand Down Expand Up @@ -276,5 +276,5 @@ def test_pirep_ete(ref: dict, icao: str, issued: datetime) -> None:
assert station.parse(reports, issued=issued) is True
assert isinstance(station.last_updated, datetime)
assert station.issued == issued
for parsed, report in zip(station.data, ref["reports"]):
for parsed, report in zip(station.data, ref["reports"], strict=True):
assert asdict(parsed) == report["data"]
2 changes: 1 addition & 1 deletion tests/current/test_taf.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def test_skc_flight_rules() -> None:
expected_flight_rules = ["MVFR", "MVFR", "VFR", "VFR", "MVFR"]
data, *_ = taf.parse(report[:4], report)
assert isinstance(data, structs.TafData)
for period, flight_rules in zip(data.forecast, expected_flight_rules):
for period, flight_rules in zip(data.forecast, expected_flight_rules, strict=True):
assert period.flight_rules == flight_rules


Expand Down
4 changes: 2 additions & 2 deletions tests/forecast/_test_gfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ def test_thunder() -> None:
"""Test that a line is converted into Number tuples."""
text = "T06 12/16 0/ 5"
_values = (None, None, (("12", 12), ("16", 16)), None, (("0", 0), ("5", 5)))
for codes, values in zip(gfs._thunder(text), _values):
for codes, values in zip(gfs._thunder(text), _values, strict=True):
if values is None:
assert codes is None
else:
assert codes is not None
for code, value in zip(codes, values):
for code, value in zip(codes, values, strict=True):
assert_number(code, *value)


Expand Down
4 changes: 2 additions & 2 deletions tests/forecast/test_nbm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_ceiling() -> None:
None,
("45", 4500, "four five hundred"),
]
for number, expected in zip(nbm._ceiling(line), values):
for number, expected in zip(nbm._ceiling(line), values, strict=True):
if expected is None:
assert number is None
else:
Expand All @@ -39,7 +39,7 @@ def test_wind() -> None:
None,
("45", 45, "four five"),
]
for number, expected in zip(nbm._wind(line), values):
for number, expected in zip(nbm._wind(line), values, strict=True):
if expected is None:
assert number is None
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/parsing/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def test_get_wind(wx: list[str], unit: str, wind: tuple[tuple], varv: list[tuple
units = structs.Units.north_american()
wx, *winds, var = core.get_wind(wx, units)
assert wx == ["1"]
for parsed, ref in zip(winds, wind):
for parsed, ref in zip(winds, wind, strict=True):
assert_number(parsed, *ref)
if varv:
assert isinstance(varv, list)
Expand Down
2 changes: 1 addition & 1 deletion tests/parsing/test_sanitization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# stdlib
import json
from collections.abc import Callable
from pathlib import Path
from typing import Callable

# library
import pytest
Expand Down
2 changes: 1 addition & 1 deletion util/build_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


def _default(o: Any) -> str | None:
return o.isoformat() if isinstance(o, (date, datetime)) else None
return o.isoformat() if isinstance(o, date | datetime) else None


def save(data: dict, path: Path) -> None:
Expand Down

0 comments on commit 5e18158

Please sign in to comment.