Skip to content

Revert disabling mypy call-overload#1374

Merged
figueroa1395 merged 4 commits intomainfrom
feature/revert-mypy-issue
Apr 21, 2026
Merged

Revert disabling mypy call-overload#1374
figueroa1395 merged 4 commits intomainfrom
feature/revert-mypy-issue

Conversation

@zhen0427
Copy link
Copy Markdown
Member

@zhen0427 zhen0427 commented Apr 16, 2026

Revert #863
Issue #867 (The mentioned test is done, no issue found with current mypy version)

Signed-off-by: zhen0427 <Zhen.Wang@alliander.com>
@zhen0427 zhen0427 added the dependencies Pull requests that update a dependency file label Apr 16, 2026
Signed-off-by: zhen0427 <Zhen.Wang@alliander.com>
Copy link
Copy Markdown
Member

@figueroa1395 figueroa1395 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhen0427 after a bit of reading (cfr. python/mypy#9003 (comment)), the CI seems to be failing because of a known bug. My understanding is that mypy has trouble understanding the types when you have signatures with Unions of Literal types, specially if they are complex. This is my understanding of this complaint:

src/power_grid_model/_core/power_grid_model.py:265:16: error: No overload variant of "create_output_data" matches argument types "set[Any] | list[Any] | ComponentAttributeFilterOptions | dict[ComponentType, set[Any] | list[Any] | ComponentAttributeFilterOptions | None] | None", "DatasetType", "Any", "bool", "int"  [call-overload]

So for this one my recommendation would be to just silence it via (line 265)

all_component_count = self._get_output_component_count(calculation_type=calculation_type)
    return create_output_data(  # type: ignore[call-overload]
...

For the other CI complaint:

tests/unit/test_power_grid_model.py:254:13: error: No overload variant of "calculate_short_circuit" of "PowerGridModel" matches argument type "str"  [call-overload]

I think the issue is that the _calculate_short_circuit definition has a default value for its argument short_circuit_voltage_scaling, which isn't reflected on the @overloads. To fix this you need to make sure the overloads have short_circuit_voltage_scaling: some_type = .... Note that = ... is what's missing after the type hint.

These should make CI happy.

@mgovers
Copy link
Copy Markdown
Member

mgovers commented Apr 21, 2026

@zhen0427 after a bit of reading (cfr. python/mypy#9003 (comment)), the CI seems to be failing because of a known bug. My understanding is that mypy has trouble understanding the types when you have signatures with Unions of Literal types, specially if they are complex. This is my understanding of this complaint:

src/power_grid_model/_core/power_grid_model.py:265:16: error: No overload variant of "create_output_data" matches argument types "set[Any] | list[Any] | ComponentAttributeFilterOptions | dict[ComponentType, set[Any] | list[Any] | ComponentAttributeFilterOptions | None] | None", "DatasetType", "Any", "bool", "int"  [call-overload]

So for this one my recommendation would be to just silence it via (line 265)

all_component_count = self._get_output_component_count(calculation_type=calculation_type)
    return create_output_data(  # type: ignore[call-overload]
...

For the other CI complaint:

tests/unit/test_power_grid_model.py:254:13: error: No overload variant of "calculate_short_circuit" of "PowerGridModel" matches argument type "str"  [call-overload]

I think the issue is that the _calculate_short_circuit definition has a default value for its argument short_circuit_voltage_scaling, which isn't reflected on the @overloads. To fix this you need to make sure the overloads have short_circuit_voltage_scaling: some_type = .... Note that = ... is what's missing after the type hint.

These should make CI happy.

the real problem with the first one is a little bit more subtle. i've already found a fix and i'm running tests as we speak.

the second one is an actual bug in our overload statements

Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
@sonarqubecloud
Copy link
Copy Markdown

Comment thread src/power_grid_model/_core/power_grid_model.py
@figueroa1395 figueroa1395 enabled auto-merge April 21, 2026 13:11
@figueroa1395 figueroa1395 added this pull request to the merge queue Apr 21, 2026
Merged via the queue into main with commit 64a3923 Apr 21, 2026
31 checks passed
@figueroa1395 figueroa1395 deleted the feature/revert-mypy-issue branch April 21, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants