Skip to content

Commit f88d163

Browse files
authored
chore: don't ignore missing imports mypy (#996)
1 parent 7cba9c5 commit f88d163

21 files changed

Lines changed: 139 additions & 43 deletions

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@ repos:
2525
- types-PyYAML
2626
- pydantic
2727
- numpy
28+
- typer
29+
- pytest
30+
- orjson
31+
- py4j
2832
- types-requests
2933
- pandas-stubs
34+
- types-networkx
35+
- types-shapely
36+
- scipy-stubs
37+
- "ruamel.yaml"
3038
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
3139
rev: v9.17.0
3240
hooks:

poetry.lock

Lines changed: 83 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ mypy = "^1.15.0"
6767
types-PyYAML = "*"
6868
types-requests = "*"
6969
pandas-stubs = "*"
70+
types-networkx = "^3.5.0.20250701"
71+
types-shapely = "^2.1.0.20250512"
72+
scipy-stubs = "^1.16.0.2"
7073

7174
[tool.poetry.extras]
7275
notebooks = ["jupyter", "matplotlib"]
@@ -97,8 +100,9 @@ markers = [
97100

98101
[tool.mypy]
99102
mypy_path = "./src"
100-
ignore_missing_imports = true
103+
ignore_missing_imports = false
101104
warn_return_any = false
105+
# warn_unreachable = true
102106
warn_unused_configs = true
103107
warn_redundant_casts = true
104108
warn_unused_ignores = true
@@ -112,7 +116,11 @@ warn_no_return = false
112116
disable_error_code = ["call-overload", "union-attr", "valid-type", "return-value", "attr-defined", "assignment"]
113117
namespace_packages = true
114118
explicit_package_bases = true
115-
plugins = ['pydantic.mypy', 'numpy.typing.mypy_plugin']
119+
plugins = ['pydantic.mypy']
120+
121+
[[tool.mypy.overrides]]
122+
module = ["py4j.*"]
123+
ignore_missing_imports = true
116124

117125
[tool.coverage.run]
118126
omit = ["^./__init__.py", "^api/.*"]

src/libecalc/common/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def id(self) -> NodeID: ...
1717

1818
class Graph(Generic[TNode]):
1919
def __init__(self):
20-
self.graph = nx.DiGraph()
20+
self.graph: nx.DiGraph = nx.DiGraph()
2121
self.nodes: dict[NodeID, TNode] = {}
2222

2323
def add_node(self, node: TNode) -> Self:

src/libecalc/common/utils/rates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def to_stream_day(calendar_day_rates: NDArray[np.float64], regularity: list[floa
4242
Returns:
4343
The corresponding stream day rates
4444
"""
45-
regularity = np.asarray(regularity, dtype=np.float64) # type: ignore[assignment]
45+
regularity = np.asarray(regularity, dtype=np.float64)
4646
return np.divide(calendar_day_rates, regularity, out=np.zeros_like(calendar_day_rates), where=regularity != 0.0) # type: ignore[comparison-overlap]
4747

4848
@staticmethod

src/libecalc/domain/infrastructure/energy_components/turbine/turbine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def evaluate(self, load: NDArray[np.float64], fuel_lower_heating_value: float =
7575

7676
# Convert arrays to lists, providing empty lists as fallback for None values
7777
load_list = array_to_list(load_adjusted) or []
78-
efficiency_list = array_to_list(efficiency) or []
78+
efficiency_list = array_to_list(efficiency) or [] # type: ignore[arg-type]
7979
fuel_usage_list = array_to_list(fuel_usage) or []
8080
exceeds_max_list = array_to_list(load > self._maximum_load) or []
8181

src/libecalc/domain/process/compressor/core/sampled/compressor_model_sampled.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def evaluate(
191191
if rate is not None:
192192
# Find indices where rate is zero and set result to zero (zero rate means machine is off)
193193
zero_rate = list(rate <= 0 if rate is not None else False)
194-
indices_set_to_zero = self._get_indices_from_condition(condition=zero_rate) # type: ignore[arg-type]
194+
indices_set_to_zero = self._get_indices_from_condition(condition=zero_rate)
195195
interpolated_consumer_values[indices_set_to_zero] = 0.0
196196

197197
"""
@@ -358,7 +358,7 @@ def calculate_turbine_power_usage(self, fuel_usage_values: NDArray[np.float64])
358358
return TurbineResult(
359359
fuel_rate=array_to_list(fuel_usage_values),
360360
efficiency=array_to_list(np.ones_like(fuel_usage_values)),
361-
load=array_to_list(load),
361+
load=array_to_list(load), # type: ignore[arg-type]
362362
energy_usage=array_to_list(fuel_usage_values), # type: ignore[arg-type]
363363
energy_usage_unit=Unit.STANDARD_CUBIC_METER_PER_DAY,
364364
power=array_to_list(power), # type: ignore

src/libecalc/domain/process/compressor/core/sampled/compressor_model_sampled_1d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ def evaluate(
128128
**kwargs,
129129
) -> NDArray[np.float64]:
130130
if self._x_column_name == RATE_NAME:
131-
return np.array(self._energy_function(rate))
131+
return np.array(self._energy_function(rate)) # type: ignore[arg-type]
132132
if self._x_column_name == PS_NAME:
133-
return np.array(self._energy_function(suction_pressure))
133+
return np.array(self._energy_function(suction_pressure)) # type: ignore[arg-type]
134134
if self._x_column_name == PD_NAME:
135-
return np.array(self._energy_function(discharge_pressure))
135+
return np.array(self._energy_function(discharge_pressure)) # type: ignore[arg-type]
136136
raise IllegalStateException(
137137
f"Unknown column name '{self._x_column_name}', allowed column names are '{RATE_NAME}', '{PS_NAME}' or '{PD_NAME}'"
138138
)

src/libecalc/domain/process/compressor/core/sampled/compressor_model_sampled_2d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def __init__(self, sampled_data: pd.DataFrame, function_header: str):
5151
# the interpolator we use when calculating energy usage
5252
self._interpolator = LinearNDInterpolator(
5353
sampled_data[self.variable_order_2d][:].values,
54-
sampled_data[function_header[:]][:].values,
54+
sampled_data[function_header[:]][:].values, # type: ignore[arg-type]
5555
fill_value=np.nan,
5656
rescale=True,
5757
)
@@ -218,7 +218,7 @@ class CompressorModelSampled2DRatePs:
218218
def __init__(self, sampled_data: pd.DataFrame, function_header: str):
219219
self._interpolator = LinearNDInterpolator(
220220
sampled_data[self.variable_order_2d][:].values,
221-
sampled_data[function_header[:]][:].values,
221+
sampled_data[function_header[:]][:].values, # type: ignore[arg-type]
222222
fill_value=np.nan,
223223
rescale=True,
224224
)
@@ -293,7 +293,7 @@ class CompressorModelSampled2DPsPd:
293293
def __init__(self, sampled_data: pd.DataFrame, function_header: str):
294294
self._interpolator = LinearNDInterpolator(
295295
sampled_data[self.variable_order_2d][:].values,
296-
sampled_data[function_header[:]][:].values,
296+
sampled_data[function_header[:]][:].values, # type: ignore[arg-type]
297297
fill_value=np.nan,
298298
rescale=True,
299299
)

src/libecalc/domain/process/compressor/core/sampled/compressor_model_sampled_3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def __init__(
134134
delaunay = Delaunay(qhull_points)
135135
interpolator = LinearNDInterpolator(
136136
points=delaunay,
137-
values=sampled_data[function_header[:]][:].values,
137+
values=sampled_data[function_header[:]][:].values, # type: ignore[arg-type]
138138
fill_value=np.nan,
139139
rescale=False,
140140
)

0 commit comments

Comments
 (0)