Skip to content

Commit

Permalink
Merge pull request #187 from woonstadrotterdam/chore/mypy-typing
Browse files Browse the repository at this point in the history
Mypy typing verbeteren
  • Loading branch information
benverhees authored Feb 19, 2025
2 parents 09ed54f + f22233f commit fede2f9
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 29 deletions.
30 changes: 17 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exclude: (wettelijke-documenten|docs)
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.4
rev: v0.5.3
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Expand Down Expand Up @@ -52,19 +52,23 @@ repos:
hooks:
- id: mypy
additional_dependencies:
[
pydantic==2.*,
types-requests==2.*,
unidecode==1.*,
PyYAML==6.*,
types-pyyaml==6.*,
libcst==1.*,
types-python-dateutil==2.*,
"rdflib==7.*",
]
- "aiohttp==3.*"
- "datamodel-code-generator==0.25.6"
- "jinja2==3.*"
- "libcst==1.*"
- "loguru==0.7.*"
- "monumenten"
- "pandas-stubs==2.*"
- "prettytable==3.*"
- "pydantic==2.*"
- "rdflib==7.*"
- "tomli==2.*"
- "types-python-dateutil==2.*"
- "types-pyyaml==6.*"
- "types-requests==2.*"
- "unidecode==1.*"
description: "Mypy is an optional static type checker for Python."
args:
["--strict", "--ignore-missing-imports", "--allow-untyped-decorators"]
args: ["--strict", "--allow-untyped-decorators"]
exclude: "tests"
stages:
- "pre-push"
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ omit = [
[project.optional-dependencies]
test = [
"pre-commit==3.3.*",
"ruff==0.3.*",
"ruff==0.5.*",
"pytest==8.*",
"pytest-cov==5.*",
"types-requests==2.*",
"types-python-dateutil==2.*",
]
dev = [
"aiohttp==3.*",
"woningwaardering[test]",
"woningwaardering[monumenten]",
"datamodel-code-generator[http]==0.25.6",
Expand Down
16 changes: 11 additions & 5 deletions scripts/genereer_corop_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from urllib.parse import urlparse

import aiohttp
import inquirer
import inquirer # type: ignore
import pandas as pd
from loguru import logger

Expand Down Expand Up @@ -105,8 +105,8 @@ async def get_woonplaats_data(session: aiohttp.ClientSession) -> pd.DataFrame:
df_pivot = df_observations.pivot(
index="Woonplaatsen", columns="Measure", values="StringValue"
)
df_pivot.columns = ["Gemeentecode"]
df_pivot = df_pivot.reset_index()
df_pivot = df_pivot.rename(columns={"GM000B": "Gemeentecode"})

return pd.merge(
df_pivot, df_woonplaatsen, left_on="Woonplaatsen", right_on="Identifier"
Expand All @@ -133,10 +133,16 @@ async def get_gemeente_corop_data(session: aiohttp.ClientSession) -> pd.DataFram

df_pivot = df_observations.pivot(
index="RegioS", columns="Measure", values="StringValue"
).reset_index()

df_pivot = df_pivot.rename(
columns={
"RegioS": "Gemeentecode",
"CR0001": "COROP-gebiedcode",
"CR0002": "COROP-gebied",
"GM000C_1": "Gemeente",
}
)
df_pivot = df_pivot.reset_index(names=["Gemeentecode"])

df_pivot.columns = ["Gemeentecode", "COROP-gebiedcode", "COROP-gebied", "Gemeente"]

return df_pivot[["Gemeentecode", "Gemeente", "COROP-gebiedcode", "COROP-gebied"]]

Expand Down
2 changes: 1 addition & 1 deletion scripts/genereer_opzet_woningwaarderinggroep.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import date
from pathlib import Path

import inquirer # noqa
import inquirer # type: ignore
from jinja2 import Environment, PackageLoader, select_autoescape

from woningwaardering.vera.referentiedata import (
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo):
# Controleer of de test een exception heeft gegeven
if call.excinfo is not None:
# Controleer of de exception een NotImplementedError is
if call.excinfo.type == NotImplementedError:
if call.excinfo is NotImplementedError:
# Maak een aangepast rapport om de test over te slaan
rep = pytest.TestReport.from_item_and_call(item, call)
rep.outcome = "skipped"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,25 @@
class Energieprestatie(Stelselgroep):
lookup_mapping = {
"energieprestatievergoeding": pd.read_csv(
files("woningwaardering").joinpath(
f"{LOOKUP_TABEL_FOLDER}/energieprestatievergoeding.csv"
str(
files("woningwaardering").joinpath(
f"{LOOKUP_TABEL_FOLDER}/energieprestatievergoeding.csv"
)
)
),
"label_ei": pd.read_csv(
files("woningwaardering").joinpath(
f"{LOOKUP_TABEL_FOLDER}/label_en_energie-index.csv"
str(
files("woningwaardering").joinpath(
f"{LOOKUP_TABEL_FOLDER}/label_en_energie-index.csv"
)
)
),
"bouwjaar": pd.read_csv(
files("woningwaardering").joinpath(f"{LOOKUP_TABEL_FOLDER}/bouwjaar.csv")
str(
files("woningwaardering").joinpath(
f"{LOOKUP_TABEL_FOLDER}/bouwjaar.csv"
)
)
),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ def __init__(
self.stelsel = Woningwaarderingstelsel.zelfstandige_woonruimten
self.stelselgroep = Woningwaarderingstelselgroep.punten_voor_de_woz_waarde
self.pd_woz_factor = pd.read_csv(
files("woningwaardering").joinpath(f"{LOOKUP_TABEL_FOLDER}/woz_factor.csv"),
str(
files("woningwaardering").joinpath(
f"{LOOKUP_TABEL_FOLDER}/woz_factor.csv"
)
),
parse_dates=["Peildatum"],
)
self.pd_minimum_woz_waarde = pd.read_csv(
files("woningwaardering").joinpath(
f"{LOOKUP_TABEL_FOLDER}/minimum_woz_waarde.csv"
str(
files("woningwaardering").joinpath(
f"{LOOKUP_TABEL_FOLDER}/minimum_woz_waarde.csv"
)
),
parse_dates=["Peildatum"],
)
Expand Down

0 comments on commit fede2f9

Please sign in to comment.