Skip to content

Commit a98116f

Browse files
authored
Type annotations update (#303)
### Added - `Calculator` now can be used as a context manager ### Changed - `Calculator` - improved initialisation and type annotations - engines `__init__` signature adjusted for consistency ### Fixed - Type annotations fix in `unit.py` - `EngineProtocol` - type annotations fix - `Calculator` - type annotations fix - Type annotations modernized to Python 3.10+ style (PEP 604, PEP 585) - `Optional[X]` → `X | None` - `Union[X, Y]` → `X | Y` - `List[X]` → `list[X]`, `Dict[K, V]` → `dict[K, V]`, `Tuple[X, Y]` → `tuple[X, Y]` - Removed unused typing imports - Updated .pyi stub files for Cython extensions - Added type guards in `uconv.py`
1 parent 620c38e commit a98116f

41 files changed

Lines changed: 1002 additions & 948 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pypi-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
cibuildwheel py_ballisticcalc.exts --output-dir dist --platform auto --archs ${{ matrix.cibw_archs }}
8787
shell: bash
8888

89-
- name: List ./dist
89+
- name: list ./dist
9090
run: ls ./dist
9191
shell: bash
9292

@@ -117,7 +117,7 @@ jobs:
117117
find ./all-dist -type f -exec cp {} dist/ \;
118118
shell: bash
119119

120-
- name: List ./dist
120+
- name: list ./dist
121121
run: ls ./dist
122122
shell: bash
123123

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.2.8] - 2026-01-26
11+
[:simple-github: GitHub release][2.2.8]
12+
13+
### Added
14+
- `Calculator` now can be used as a context manager
15+
16+
### Changed
17+
- `Calculator` - improved initialisation and type annotations
18+
- engines `__init__` signature adjusted for consistency
19+
20+
### Fixed
21+
- Type annotations fix in `unit.py`
22+
- `EngineProtocol` - type annotations fix
23+
- `Calculator` - type annotations fix
24+
- Type annotations modernized to Python 3.10+ style (PEP 604, PEP 585)
25+
- `Optional[X]``X | None`
26+
- `Union[X, Y]``X | Y`
27+
- `List[X]``list[X]`, `Dict[K, V]``dict[K, V]`, `Tuple[X, Y]``tuple[X, Y]`
28+
- Removed unused typing imports
29+
- Updated .pyi stub files for Cython extensions
30+
- Added type guards in `uconv.py`
31+
1032
## [2.2.7] - 2025-12-26
1133
[:simple-github: GitHub release][2.2.7]
1234

@@ -500,7 +522,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
500522
- Issue #141
501523
- Trajectories that bend backwards
502524

503-
[Unreleased]: https://github.com/o-murphy/py-ballisticcalc/compare/v2.2.7...HEAD
525+
[Unreleased]: https://github.com/o-murphy/py-ballisticcalc/compare/v2.2.8...HEAD
526+
[2.2.8]: https://github.com/o-murphy/py-ballisticcalc/releases/tag/v2.2.8
504527
[2.2.7]: https://github.com/o-murphy/py-ballisticcalc/releases/tag/v2.2.7
505528
[2.2.6.post1]: https://github.com/o-murphy/py-ballisticcalc/releases/tag/v2.2.6.post1
506529
[2.2.6]: https://github.com/o-murphy/py-ballisticcalc/releases/tag/v2.2.6

examples/aerial_target/aerial_target.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import math
33
from dataclasses import dataclass, field
44

5-
from typing_extensions import Union, NamedTuple, Tuple
5+
from typing import Union, NamedTuple
66

77
from py_ballisticcalc import *
88

@@ -88,7 +88,7 @@ def __repr__(self):
8888
fields = ', '.join(f"{k}={v!r}" for k, v in preferred.items())
8989
return f"AerialTarget({fields})"
9090

91-
def at_time(self, time_of_flight: float) -> Tuple['AerialTarget', AerialTargetPosition]:
91+
def at_time(self, time_of_flight: float) -> tuple['AerialTarget', AerialTargetPosition]:
9292
[
9393
velocity_fps,
9494
slant_distance_ft,

examples/performance_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def run_check(calc_: Calculator, number: int):
131131
print(f"Total time: {total_time:.6f} seconds")
132132
print(f"Execution rate: {rate:.2f} calls per second")
133133

134-
if calc_._engine_class.__name__.lower().startswith("cythonized"):
134+
if calc_._engine_factory.__name__.lower().startswith("cythonized"):
135135
key_attribute = 'position.x'
136136
target_value = shot_distance._feet
137137

0 commit comments

Comments
 (0)