Skip to content

Fix: Incorrect use of typing.Union #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI

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

permissions:
contents: read

jobs:
test:
name: ci ${{ matrix.python-version }}
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
uses: actions/setup-go@v5
with:
go-version: '1.22'
cache-dependency-path: tests/clients/go/go.sum
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 22
cache: maven
cache-dependency-path: tests/clients/java/pom.xml
- name: Set up Python
uses: actions/setup-python@v5
with:
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 tox
- name: Test
run: tox -e py
- name: Lint
if: matrix.python-version == '3.12'
run: tox -e lint
48 changes: 0 additions & 48 deletions .github/workflows/python.yml

This file was deleted.

20 changes: 10 additions & 10 deletions mmdb_writer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.2.1"
__version__ = "0.2.2"

import logging
import math
Expand All @@ -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 = "me@vimt.me" } ]
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