Skip to content

Commit

Permalink
ci: use tox and support from python3.8
Browse files Browse the repository at this point in the history
fix: wrong use typing.Union
  • Loading branch information
vimt committed Jun 3, 2024
1 parent 6704a52 commit 7a34c8e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 31 deletions.
36 changes: 17 additions & 19 deletions .github/workflows/python.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application
name: CI

on:
push:
branches: [ "master" ]
branches: [ "master", "ci/*" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read

jobs:
build:

test:
name: ${{ matrix.name || matrix.python }}
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Setup Go environment
Expand All @@ -29,20 +28,19 @@ jobs:
distribution: temurin
java-version: 22
cache: maven
- name: Set up Python 3.10
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: pip
python-version: ${{ matrix.python-version }}
allow-prereleases: true
check-latest: true
- name: Install dependencies
run: |
sudo apt install libmaxminddb0 libmaxminddb-dev
python -m pip install --upgrade pip
pip install ".[test,dev]"
- name: Check with ruff
run: |
ruff check
ruff format --check
- name: Test with pytest
run: |
pytest
pip install tox
- name: test
run: tox -e py
- name: lint
if: matrix.python-version == '3.12'
run: tox -e lint
18 changes: 9 additions & 9 deletions mmdb_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, value: float):


class MmdbF64(MmdbBaseType):
def __init__(self, value: Union[float | Decimal]):
def __init__(self, value: Union[float, Decimal]):
super().__init__(value)


Expand Down Expand Up @@ -145,14 +145,14 @@ def __repr__(self):
"uint64",
"uint128",
"int32",
]
| MmdbU16
| MmdbU32
| MmdbU64
| MmdbU128
| MmdbI32
],
MmdbU16,
MmdbU32,
MmdbU64,
MmdbU128,
MmdbI32,
]
FloatType = Union[Literal["f32", "f64", "float32", "float64"] | MmdbF32 | MmdbF64]
FloatType = Union[Literal["f32", "f64", "float32", "float64"], MmdbF32, MmdbF64]


class Encoder:
Expand Down Expand Up @@ -547,7 +547,7 @@ def __init__(
ip_version=4,
database_type="GeoIP",
languages: List[str] = None,
description: Union[Dict[str, str] | str] = "GeoIP db",
description: Union[Dict[str, str], str] = "GeoIP db",
ipv4_compatible=False,
int_type: IntType = "auto",
float_type: FloatType = "f64",
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "mmdb_writer"
description = "Make `mmdb` format ip library file which can be read by maxmind official language reader"
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.6"
requires-python = ">=3.8"
keywords = ["mmdb", "maxmind"]
authors = [{ name = "VimT", email = "[email protected]" } ]
classifiers = [
Expand All @@ -16,8 +16,9 @@ classifiers = [
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"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",
Expand Down
16 changes: 16 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tox]
envlist =
py3{13,12,11,10,9,8}
lint
skip_missing_interpreters = true

[testenv]
description = run unit tests
extras = test
commands = pytest

[testenv:lint]
extras = dev
commands =
ruff check --no-fix
ruff format --check

0 comments on commit 7a34c8e

Please sign in to comment.