Skip to content

Commit 6729a3a

Browse files
committed
chore: update Python version to 3.9 and enhance type hints in geocode functions
1 parent 21ab647 commit 6729a3a

File tree

4 files changed

+102
-7
lines changed

4 files changed

+102
-7
lines changed

.github/workflows/ci.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Monorepo CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- "libs/javascript/**"
8+
- "libs/python/**"
9+
- ".github/workflows/**"
10+
pull_request:
11+
paths:
12+
- "libs/javascript/**"
13+
- "libs/python/**"
14+
- ".github/workflows/**"
15+
workflow_dispatch:
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
changes:
22+
runs-on: ubuntu-latest
23+
outputs:
24+
javascript: ${{ steps.filter.outputs.javascript }}
25+
python: ${{ steps.filter.outputs.python }}
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Detect changed paths
31+
id: filter
32+
uses: dorny/paths-filter@v3
33+
with:
34+
filters: |
35+
javascript:
36+
- 'libs/javascript/**'
37+
python:
38+
- 'libs/python/**'
39+
40+
javascript:
41+
name: JavaScript checks
42+
needs: changes
43+
if: needs.changes.outputs.javascript == 'true'
44+
runs-on: ubuntu-latest
45+
defaults:
46+
run:
47+
working-directory: libs/javascript
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@v4
51+
52+
- name: Setup Bun
53+
uses: oven-sh/setup-bun@v2
54+
with:
55+
bun-version: "1.2.20"
56+
57+
- name: Install dependencies
58+
run: bun install --frozen-lockfile
59+
60+
- name: Run checks
61+
run: bun run check
62+
63+
python:
64+
name: Python checks
65+
needs: changes
66+
if: needs.changes.outputs.python == 'true'
67+
runs-on: ubuntu-latest
68+
defaults:
69+
run:
70+
working-directory: libs/python
71+
steps:
72+
- name: Checkout repository
73+
uses: actions/checkout@v4
74+
75+
- name: Setup Python
76+
uses: actions/setup-python@v5
77+
with:
78+
python-version: "3.12"
79+
80+
- name: Install dependencies
81+
run: |
82+
python -m pip install --upgrade pip
83+
pip install -e ".[dev]"
84+
85+
- name: Run lint
86+
run: ruff check .
87+
88+
- name: Run type check
89+
run: mypy lakhua --ignore-missing-imports
90+
91+
- name: Run tests
92+
run: pytest
93+

libs/python/lakhua/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
This library provides in-memory reverse geocoding using H3 spatial indexing.
55
"""
66

7+
from typing import Optional
8+
79
from lakhua.core import (
810
DATA_DIR_NAME,
911
DATA_FILE_PREFIX,
@@ -43,8 +45,8 @@
4345
def geocode(
4446
lat: float,
4547
lon: float,
46-
options: GeocodeOptions | None = None,
47-
) -> GeocodeResult | None:
48+
options: Optional[GeocodeOptions] = None,
49+
) -> Optional[GeocodeResult]:
4850
"""
4951
Reverse geocodes latitude/longitude into India location metadata.
5052
@@ -69,8 +71,8 @@ def geocode(
6971

7072
def geocode_h3(
7173
h3_index: str,
72-
options: GeocodeOptions | None = None,
73-
) -> GeocodeResult | None:
74+
options: Optional[GeocodeOptions] = None,
75+
) -> Optional[GeocodeResult]:
7476
"""
7577
Reverse geocodes an H3 cell index directly.
7678

libs/python/lakhua/core/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import json
1010
from pathlib import Path
11-
from typing import Dict
11+
from typing import Dict, cast
1212

1313
# Resolution configuration
1414
MIN_RESOLUTION: int = 4
@@ -87,5 +87,5 @@ def read_reverse_geo_store(resolution: int) -> Dict[str, Dict[str, str]]:
8787
return {}
8888

8989
with open(file_path, encoding="utf-8") as f:
90-
return json.load(f)
90+
return cast(Dict[str, Dict[str, str]], json.load(f))
9191

libs/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ select = ["E", "F", "I", "N", "W", "UP"]
5858
ignore = []
5959

6060
[tool.mypy]
61-
python_version = "3.8"
61+
python_version = "3.9"
6262
strict = true
6363
warn_return_any = true
6464
warn_unused_configs = true

0 commit comments

Comments
 (0)