Skip to content

Commit

Permalink
minimal type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
alphahm committed Apr 6, 2024
1 parent bb7ac29 commit 28e8365
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- name: lint
run: |
black --check src/
- name: mypy
run: |
mypy src
- name: Test with pytest
run: |
pytest
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ venv
dist
build
.coverage
.idea
.idea
*.swp
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
black==22.6.0
pytest==7.1.2
pytest-cov==3.0.0
pytest-mock==3.8.2
pytest-mock==3.8.2
mypy==1.9.0
10 changes: 5 additions & 5 deletions src/adhanpy/PrayerTimes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime, timedelta, timezone
from typing import Optional
from zoneinfo import ZoneInfo
from typing import Tuple
from adhanpy.calculation.CalculationMethod import CalculationMethod
from adhanpy.calculation.CalculationParameters import CalculationParameters
from adhanpy.calculation.Twilight import (
Expand All @@ -18,11 +18,11 @@
class PrayerTimes:
def __init__(
self,
coordinates: Tuple[float, float],
coordinates: tuple[float, float],
date: datetime,
calculation_method: CalculationMethod = None,
calculation_parameters: CalculationParameters = None,
time_zone: ZoneInfo = None,
calculation_method: Optional[CalculationMethod] = None,
calculation_parameters: Optional[CalculationParameters] = None,
time_zone: Optional[ZoneInfo] = None,
):
"""
Arguments:
Expand Down
6 changes: 3 additions & 3 deletions src/adhanpy/calculation/CalculationParameters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional
from typing import Any, Optional
from adhanpy.calculation.CalculationMethod import CalculationMethod
from adhanpy.calculation.MethodsParameters import methods_parameters
from adhanpy.calculation.MethodsParameters import METHODS_PARAMETERS
from adhanpy.calculation.Madhab import Madhab
from adhanpy.calculation.HighLatitudeRule import HighLatitudeRule
from adhanpy.calculation.PrayerAdjustments import PrayerAdjustments
Expand Down Expand Up @@ -62,6 +62,6 @@ def night_portions(self) -> NightPortions:
raise ValueError("Invalid high latitude rule")

def _set_parameters_using_method(self) -> None:
method_parameters = methods_parameters[self.method]
method_parameters = METHODS_PARAMETERS[self.method]
for key, value in method_parameters.items():
setattr(self, key, value)
5 changes: 3 additions & 2 deletions src/adhanpy/calculation/MethodsParameters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from typing import Any

from adhanpy.calculation.CalculationMethod import CalculationMethod
from adhanpy.calculation.PrayerAdjustments import PrayerAdjustments


methods_parameters = {
METHODS_PARAMETERS: dict[CalculationMethod, dict[str, Any]] = {
CalculationMethod.NONE: {},
CalculationMethod.MUSLIM_WORLD_LEAGUE: {
"fajr_angle": 18.0,
Expand Down

0 comments on commit 28e8365

Please sign in to comment.