Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pytest and pylint warnings #884

Merged
merged 8 commits into from
Nov 20, 2024
Merged

Fix pytest and pylint warnings #884

merged 8 commits into from
Nov 20, 2024

Conversation

jeandemanged
Copy link
Member

@jeandemanged jeandemanged commented Nov 6, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?

No

What kind of change does this PR introduce?

Quality

What is the current behavior?

Many warnings, especially in pytest, making it hard for developers to spot whether new ones are introduced.

Some are real warnings to be adressed, others are pypowsybl deprecated features/apis warnings which should be filtered/checked because expected.

Also some pylint issues to be addressed if relevant.

pytest: 328 warnings
pylint: 9.84/10

pytest

=================================================================== test session starts ====================================================================
platform linux -- Python 3.12.2, pytest-8.3.3, pluggy-1.5.0
rootdir: /home/djeandemange/powsybl/pypowsybl
configfile: pytest.ini
collected 400 items

tests/test_dynamic.py .....                                                                                                                          [  1%]
tests/test_flow_decomposition.py .................                                                                                                   [  5%]
tests/test_glsk.py ...                                                                                                                               [  6%]
tests/test_import.py .                                                                                                                               [  6%]
tests/test_java_perunit.py .....................                                                                                                     [ 11%]
tests/test_loadflow.py .....................                                                                                                         [ 17%]
tests/test_logging.py .                                                                                                                              [ 17%]
tests/test_network.py ...........................................................................s..........s..................................      [ 47%]
tests/test_network_elements_creation.py .......................................                                                                      [ 57%]
tests/test_network_extensions.py .........................                                                                                           [ 63%]
tests/test_network_modification.py ..............................................................                                                    [ 79%]
tests/test_network_pickle.py .                                                                                                                       [ 79%]
tests/test_network_reduction.py ...                                                                                                                  [ 80%]
tests/test_pandapower.py .............                                                                                                               [ 83%]
tests/test_per_unit.py ....................                                                                                                          [ 88%]
tests/test_security_analysis.py ........................                                                                                             [ 94%]
tests/test_sensitivity_analysis.py ..................                                                                                                [ 98%]
tests/test_shortcircuit_analysis.py ...                                                                                                              [ 99%]
tests/test_voltage_initializer.py .s                                                                                                                 [100%]

===================================================================== warnings summary =====================================================================
tests/test_java_perunit.py::test_generator_per_unit
  /home/djeandemange/powsybl/pypowsybl/tests/test_java_perunit.py:80: FutureWarning: Mismatched null-like values None and nan found. In a future version, pandas equality-testing functions (e.g. assert_frame_equal) will consider these not-matching and raise.
    pd.testing.assert_frame_equal(expected, n.get_generators(), check_dtype=False, atol=1e-2)

tests/test_java_perunit.py: 3 warnings
tests/test_network.py: 57 warnings
tests/test_network_elements_creation.py: 22 warnings
tests/test_network_extensions.py: 21 warnings
tests/test_network_modification.py: 7 warnings
tests/test_pandapower.py: 111 warnings
tests/test_per_unit.py: 3 warnings
tests/test_security_analysis.py: 1 warning
tests/test_sensitivity_analysis.py: 1 warning
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/utils/impl/dataframes.py:107: DeprecationWarning: In future, it will be an error for 'np.bool_' scalars to be interpreted as an index
    return _pp.create_dataframe(columns_values, columns_names, columns_types, is_index)

tests/test_java_perunit.py::test_generator_per_unit
  /home/djeandemange/powsybl/pypowsybl/tests/test_java_perunit.py:96: FutureWarning: Mismatched null-like values None and nan found. In a future version, pandas equality-testing functions (e.g. assert_frame_equal) will consider these not-matching and raise.
    pd.testing.assert_frame_equal(expected, n.get_generators(), check_dtype=False, atol=1e-2)

tests/test_loadflow.py: 1 warning
tests/test_network_modification.py: 14 warnings
tests/test_security_analysis.py: 1 warning
tests/test_sensitivity_analysis.py: 1 warning
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/report/impl/reporter.py:18: DeprecationWarning: Use of deprecated attribute reporter. Use report_node instead.
    warnings.warn(DEPRECATED_REPORTER_WARNING, DeprecationWarning)

tests/test_loadflow.py: 3 warnings
tests/test_network_modification.py: 28 warnings
tests/test_security_analysis.py: 2 warnings
tests/test_sensitivity_analysis.py: 2 warnings
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/report/impl/reporter.py:22: DeprecationWarning: Use of deprecated attribute reporter. Use report_node instead.
    warnings.warn(DEPRECATED_REPORTER_WARNING, DeprecationWarning)

tests/test_loadflow.py::test_run_lf_with_deprecated_reporter
tests/test_loadflow.py::test_run_lf_with_deprecated_reporter
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/loadflow/impl/loadflow.py:51: DeprecationWarning: Use of deprecated attribute reporter. Use report_node instead.
    warnings.warn("Use of deprecated attribute reporter. Use report_node instead.", DeprecationWarning)

tests/test_loadflow.py::test_run_lf_with_deprecated_reporter
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/report/impl/reporter.py:31: DeprecationWarning: Use of deprecated attribute reporter. Use report_node instead.
    warnings.warn(DEPRECATED_REPORTER_WARNING, DeprecationWarning)

tests/test_network.py::test_layout_parameters
tests/test_network.py::test_layout_parameters
tests/test_network.py::test_sld_svg_backward_compatibility
tests/test_network.py::test_sld_svg_backward_compatibility
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/network/impl/layout_parameters.py:22: DeprecationWarning: LayoutParameters is deprecated, use SldParameters instead
    warnings.warn("LayoutParameters is deprecated, use SldParameters instead", DeprecationWarning)

tests/test_network.py::test_current_limits
tests/test_network.py::test_current_limits
tests/test_network.py::test_current_limits
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/network/impl/network.py:3614: DeprecationWarning: get_current_limits is deprecated, use get_operational_limits instead
    warnings.warn("get_current_limits is deprecated, use get_operational_limits instead", DeprecationWarning)

tests/test_network.py::test_current_limits
  /home/djeandemange/powsybl/pypowsybl/tests/test_network.py:1116: PerformanceWarning: indexing past lexsort depth may impact performance.
    current_limit = network.get_current_limits().loc['NHV1_NHV2_1', '10\'']

tests/test_network.py::test_load_network_with_report
tests/test_network.py::test_save_to_string_with_report
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/network/impl/network_creation_util.py:209: DeprecationWarning: Use of deprecated attribute reporter. Use report_node instead.
    warnings.warn(DEPRECATED_REPORTER_WARNING, DeprecationWarning)

tests/test_network.py::test_load_network_from_string_with_report
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/network/impl/network_creation_util.py:286: DeprecationWarning: Use of deprecated attribute reporter. Use report_node instead.
    warnings.warn(DEPRECATED_REPORTER_WARNING, DeprecationWarning)

tests/test_network.py::test_deprecated_operational_limits_is_fictitious
tests/test_network.py::test_deprecated_operational_limits_element_type
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/network/impl/network.py:4665: DeprecationWarning: operation limits is_fictitious attribute has been renamed fictitious
    warnings.warn("operation limits is_fictitious attribute has been renamed fictitious", DeprecationWarning)

tests/test_network.py::test_deprecated_operational_limits_is_fictitious_kwargs
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/network/impl/network.py:4672: DeprecationWarning: operation limits is_fictitious attribute has been renamed fictitious
    warnings.warn("operation limits is_fictitious attribute has been renamed fictitious", DeprecationWarning)

tests/test_network.py::test_deprecated_operational_limits_is_fictitious_kwargs
tests/test_network.py::test_deprecated_operational_limits_element_type_kwargs
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/network/impl/network.py:4675: DeprecationWarning: useless operation limits element_type attribute has been removed
    warnings.warn("useless operation limits element_type attribute has been removed", DeprecationWarning)

tests/test_network.py::test_deprecated_operational_limits_element_type
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/network/impl/network.py:4668: DeprecationWarning: useless operation limits element_type attribute has been removed
    warnings.warn("useless operation limits element_type attribute has been removed", DeprecationWarning)

tests/test_network_elements_creation.py::test_tie_line_creation
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/network/impl/network.py:3991: DeprecationWarning: ucte_xnode_code is deprecated, use pairing_key
    warnings.warn(ucte_xnode_code_str + " is deprecated, use pairing_key", DeprecationWarning)

tests/test_per_unit.py: 18 warnings
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/network/impl/perunit.py:34: DeprecationWarning: Per-unit view is deprecated and slow (make a deep copy of the network), use per unit mode of the network instead
    warnings.warn("Per-unit view is deprecated and slow (make a deep copy of the network), use per unit mode of the network instead", DeprecationWarning)

tests/test_per_unit.py::test_generator_per_unit
  /home/djeandemange/powsybl/pypowsybl/tests/test_per_unit.py:54: FutureWarning: Mismatched null-like values None and nan found. In a future version, pandas equality-testing functions (e.g. assert_frame_equal) will consider these not-matching and raise.
    pd.testing.assert_frame_equal(expected, n.get_generators(), check_dtype=False, atol=1e-2)

tests/test_per_unit.py::test_generator_per_unit
  /home/djeandemange/powsybl/pypowsybl/tests/test_per_unit.py:69: FutureWarning: Mismatched null-like values None and nan found. In a future version, pandas equality-testing functions (e.g. assert_frame_equal) will consider these not-matching and raise.
    pd.testing.assert_frame_equal(expected, n.get_generators(), check_dtype=False, atol=1e-2)

tests/test_security_analysis.py::test_ac_security_analysis_with_deprecated_report
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/security/impl/security.py:47: DeprecationWarning: Use of deprecated attribute reporter. Use report_node instead.
    warnings.warn("Use of deprecated attribute reporter. Use report_node instead.", DeprecationWarning)

tests/test_sensitivity_analysis.py::test_config
tests/test_sensitivity_analysis.py::test_no_output_matrices_available
tests/test_sensitivity_analysis.py::test_provider_parameters
tests/test_sensitivity_analysis.py::test_sensitivity_parameters
tests/test_sensitivity_analysis.py::test_hvdc
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/sensitivity/impl/sensitivity.py:76: DeprecationWarning: set_branch_flow_factor_matrix is deprecated, use add_branch_flow_factor_matrix instead
    warnings.warn("set_branch_flow_factor_matrix is deprecated, use add_branch_flow_factor_matrix instead",

tests/test_sensitivity_analysis.py::test_voltage_sensitivities_with_deprecated_report
  /home/djeandemange/powsybl/pypowsybl/pypowsybl/sensitivity/impl/ac_sensitivity_analysis.py:73: DeprecationWarning: Use of deprecated attribute reporter. Use report_node instead.
    warnings.warn("Use of deprecated attribute reporter. Use report_node instead.", DeprecationWarning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================= 397 passed, 3 skipped, 328 warnings in 7.79s =======================================================

pylint

pylint: Command line or configuration file:1: UserWarning: 'BaseException' is not a proper value for the 'overgeneral-exceptions' option. Use fully qualified name (maybe 'builtins.BaseException' ?) instead. This will cease to be checked at runtime when the configuration upgrader is released.
pylint: Command line or configuration file:1: UserWarning: 'Exception' is not a proper value for the 'overgeneral-exceptions' option. Use fully qualified name (maybe 'builtins.Exception' ?) instead. This will cease to be checked at runtime when the configuration upgrader is released.
************* Module pypowsybl._pypowsybl
pypowsybl/_pypowsybl.pyi:109:34: E0601: Using variable 'LimitViolationArray' before assignment (used-before-assignment)
pypowsybl/_pypowsybl.pyi:111:24: E0601: Using variable 'PostContingencyComputationStatus' before assignment (used-before-assignment)
pypowsybl/_pypowsybl.pyi:125:24: E0601: Using variable 'LoadFlowComponentStatus' before assignment (used-before-assignment)
pypowsybl/_pypowsybl.pyi:345:22: E0601: Using variable 'Side' before assignment (used-before-assignment)
pypowsybl/_pypowsybl.pyi:439:23: E0601: Using variable 'VoltageInitMode' before assignment (used-before-assignment)
pypowsybl/_pypowsybl.pyi:492:33: C0321: More than one statement on a single line (multiple-statements)
pypowsybl/_pypowsybl.pyi:751:93: W0622: Redefining built-in 'open' (redefined-builtin)
pypowsybl/_pypowsybl.pyi:3:0: C0411: standard import "logging.Logger" should be placed before third party import "numpy.typing.ArrayLike" (wrong-import-order)
************* Module pypowsybl.network.impl.network_element_modification_util
pypowsybl/network/impl/network_element_modification_util.py:647:0: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
************* Module pypowsybl.network.impl.pandapower_converter
pypowsybl/network/impl/pandapower_converter.py:303:9: W0511: TODO topology kind should have a default value (fixme)
pypowsybl/network/impl/pandapower_converter.py:33:4: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise)
pypowsybl/network/impl/pandapower_converter.py:65:44: R1719: The if expression can be replaced with 'test' (simplifiable-if-expression)
pypowsybl/network/impl/pandapower_converter.py:55:12: W0612: Unused variable 'index' (unused-variable)
pypowsybl/network/impl/pandapower_converter.py:84:11: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
pypowsybl/network/impl/pandapower_converter.py:94:11: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
pypowsybl/network/impl/pandapower_converter.py:104:11: C0209: Formatting a regular string which could be an f-string (consider-using-f-string)
pypowsybl/network/impl/pandapower_converter.py:258:21: W3601: Suspicious 2-part chained comparison using semantically incompatible operators ('==' and 'in') (bad-chained-comparison)
pypowsybl/network/impl/pandapower_converter.py:16:0: C0411: third party import "pandas.Series" should be placed before first party import "pypowsybl._pypowsybl"  (wrong-import-order)
pypowsybl/network/impl/pandapower_converter.py:17:0: C0411: third party import "pandas.DataFrame" should be placed before first party import "pypowsybl._pypowsybl"  (wrong-import-order)
************* Module pypowsybl.network.impl.network
pypowsybl/network/impl/network.py:1:0: C0302: Too many lines in module (5145/5000) (too-many-lines)
pypowsybl/network/impl/network.py:3654:8: R1705: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it (no-else-return)
************* Module pypowsybl.utils.impl.util
pypowsybl/utils/impl/util.py:38:11: C2801: Unnecessarily calls dunder method __fspath__. Use os.fspath function instead. (unnecessary-dunder-call)
************* Module pypowsybl.security.impl.security
pypowsybl/security/impl/security.py:186:64: W0622: Redefining built-in 'open' (redefined-builtin)
************* Module pypowsybl.voltage_initializer.impl.voltage_initializer_parameters
pypowsybl/voltage_initializer/impl/voltage_initializer_parameters.py:187:0: C0303: Trailing whitespace (trailing-whitespace)
pypowsybl/voltage_initializer/impl/voltage_initializer_parameters.py:335:0: C0305: Trailing newlines (trailing-newlines)
pypowsybl/voltage_initializer/impl/voltage_initializer_parameters.py:41:0: R0904: Too many public methods (27/20) (too-many-public-methods)
************* Module pypowsybl.report.impl.report_node
pypowsybl/report/impl/report_node.py:15:4: E0306: __repr__ does not return str (invalid-repr-returned)
************* Module pypowsybl.report.impl.reporter
pypowsybl/report/impl/reporter.py:21:4: E0306: __repr__ does not return str (invalid-repr-returned)
************* Module pypowsybl.sensitivity.impl.sensitivity
pypowsybl/sensitivity/impl/sensitivity.py:1:0: R0801: Similar lines in 2 files
==pypowsybl.network.impl.network_element_modification_util:[711:719]
==pypowsybl.utils.impl.dataframes:[181:187]
    for i, df in enumerate(dfs):
        if df is None:
            c_dfs.append(None)
        else:
            c_dfs.append(_create_c_dataframe(df, metadata[i]))
    return c_dfs

 (duplicate-code)
pypowsybl/sensitivity/impl/sensitivity.py:1:0: R0801: Similar lines in 2 files
==pypowsybl.loadflow.impl.parameters:[154:160]
==pypowsybl.security.impl.parameters:[72:78]
        c_parameters.provider_parameters_keys = list(self.provider_parameters.keys())
        c_parameters.provider_parameters_values = list(self.provider_parameters.values())
        return c_parameters

    def __repr__(self) -> str:
        return f"{self.__class__.__name__}(" \ (duplicate-code)
pypowsybl/sensitivity/impl/sensitivity.py:1:0: R0801: Similar lines in 2 files
==pypowsybl.network.impl.network:[4392:4397]
==pypowsybl.network.impl.network_element_modification_util:[392:397]
    if linear_model_df is None:
        linear_model_df = pd.DataFrame()
    if non_linear_model_df is None:
        non_linear_model_df = pd.DataFrame()
    dfs: List[Optional[DataFrame]] = [shunt_df, linear_model_df, non_linear_model_df] (duplicate-code)
pypowsybl/sensitivity/impl/sensitivity.py:1:0: R0401: Cyclic import (pypowsybl.report -> pypowsybl.report.impl.reporter) (cyclic-import)


Report
======
3837 statements analysed.

Statistics by type
------------------

+---------+-------+-----------+-----------+------------+---------+
|type     |number |old number |difference |%documented |%badname |
+=========+=======+===========+===========+============+=========+
|module   |80     |80         |=          |15.00       |0.00     |
+---------+-------+-----------+-----------+------------+---------+
|class    |103    |103        |=          |33.98       |0.00     |
+---------+-------+-----------+-----------+------------+---------+
|method   |703    |703        |=          |87.20       |0.00     |
+---------+-------+-----------+-----------+------------+---------+
|function |320    |320        |=          |31.56       |0.00     |
+---------+-------+-----------+-----------+------------+---------+



External dependencies
---------------------
::

    networkx (pypowsybl.network.impl.bus_breaker_topology,pypowsybl.network.impl.node_breaker_topology)
    numpy (pypowsybl.network.impl.network,pypowsybl.network.impl.pandapower_converter,pypowsybl.sensitivity.impl.sensitivity_analysis_result,pypowsybl.utils.impl.dataframes)
      \-typing (pypowsybl._pypowsybl,pypowsybl.network.impl.network,pypowsybl.network.impl.network_element_modification_util,pypowsybl.network.impl.perunit,pypowsybl.shortcircuit.impl.short_circuit_analysis,pypowsybl.utils.impl.dataframes)
    pandapower (pypowsybl.network.impl.pandapower_converter)
    pandas (pypowsybl.dynamic.impl.model_mapping,pypowsybl.dynamic.impl.simulation_result,pypowsybl.flowdecomposition.impl.flowdecomposition,pypowsybl.loadflow.impl.loadflow,pypowsybl.loadflow.impl.validation_result,pypowsybl.network.impl.bus_breaker_topology,pypowsybl.network.impl.network,pypowsybl.network.impl.network_element_modification_util,pypowsybl.network.impl.node_breaker_topology,pypowsybl.network.impl.pandapower_converter,pypowsybl.network.impl.perunit,pypowsybl.network.impl.util,pypowsybl.security.impl.security_analysis_result,pypowsybl.sensitivity.impl.ac_sensitivity_analysis_result,pypowsybl.sensitivity.impl.dc_sensitivity_analysis_result,pypowsybl.sensitivity.impl.sensitivity_analysis_result,pypowsybl.shortcircuit.impl.short_circuit_analysis,pypowsybl.shortcircuit.impl.short_circuit_analysis_result,pypowsybl.utils.impl.dataframes,pypowsybl.utils.impl.util)
    prettytable (pypowsybl.security.impl.security_analysis_result)
    pypowsybl
      \-_pypowsybl (pypowsybl.dynamic.impl.curve_mapping,pypowsybl.dynamic.impl.event_mapping,pypowsybl.dynamic.impl.model_mapping,pypowsybl.dynamic.impl.simulation,pypowsybl.dynamic.impl.simulation_result,pypowsybl.flowdecomposition.impl.flowdecomposition,pypowsybl.flowdecomposition.impl.parameters,pypowsybl.flowdecomposition.impl.util,pypowsybl.glsk.impl.glsk_document,pypowsybl.glsk.impl.util,pypowsybl.loadflow.impl.component_result,pypowsybl.loadflow.impl.loadflow,pypowsybl.loadflow.impl.parameters,pypowsybl.loadflow.impl.slack_bus_result,pypowsybl.loadflow.impl.util,pypowsybl.loadflow.impl.validation_parameters,pypowsybl.network,pypowsybl.network.impl.bus_breaker_topology,pypowsybl.network.impl.nad_parameters,pypowsybl.network.impl.network,pypowsybl.network.impl.network_creation_util,pypowsybl.network.impl.network_element_modification_util,pypowsybl.network.impl.node_breaker_topology,pypowsybl.network.impl.pandapower_converter,pypowsybl.network.impl.sld_parameters,pypowsybl.network.impl.util,pypowsybl.report.impl.report_node,pypowsybl.report.impl.reporter,pypowsybl.security.impl.contingency_container,pypowsybl.security.impl.parameters,pypowsybl.security.impl.security,pypowsybl.security.impl.security_analysis_result,pypowsybl.security.impl.util,pypowsybl.sensitivity,pypowsybl.sensitivity.impl.ac_sensitivity_analysis,pypowsybl.sensitivity.impl.ac_sensitivity_analysis_result,pypowsybl.sensitivity.impl.dc_sensitivity_analysis,pypowsybl.sensitivity.impl.dc_sensitivity_analysis_result,pypowsybl.sensitivity.impl.parameters,pypowsybl.sensitivity.impl.sensitivity,pypowsybl.sensitivity.impl.sensitivity_analysis_result,pypowsybl.sensitivity.impl.util,pypowsybl.sensitivity.impl.zone,pypowsybl.shortcircuit.impl.parameters,pypowsybl.shortcircuit.impl.short_circuit_analysis,pypowsybl.shortcircuit.impl.short_circuit_analysis_result,pypowsybl.shortcircuit.impl.util,pypowsybl.utils.impl.dataframes,pypowsybl.utils.impl.util,pypowsybl.voltage_initializer.impl.voltage_initializer,pypowsybl.voltage_initializer.impl.voltage_initializer_parameters,pypowsybl.voltage_initializer.impl.voltage_initializer_results)
      \-glsk (pypowsybl.sensitivity.impl.util)
      \-loadflow (pypowsybl.flowdecomposition.impl.flowdecomposition,pypowsybl.security.impl.parameters,pypowsybl.security.impl.security,pypowsybl.sensitivity.impl.ac_sensitivity_analysis,pypowsybl.sensitivity.impl.dc_sensitivity_analysis,pypowsybl.sensitivity.impl.parameters)
      | \-impl
      |   \-util (pypowsybl.security.impl.parameters,pypowsybl.sensitivity.impl.parameters)
      \-network (pypowsybl.dynamic.impl.simulation,pypowsybl.flowdecomposition.impl.flowdecomposition,pypowsybl.glsk.impl.glsk_document,pypowsybl.loadflow.impl.loadflow,pypowsybl.security.impl.security,pypowsybl.sensitivity.impl.ac_sensitivity_analysis,pypowsybl.sensitivity.impl.dc_sensitivity_analysis,pypowsybl.sensitivity.impl.util,pypowsybl.shortcircuit.impl.short_circuit_analysis,pypowsybl.voltage_initializer.impl.voltage_initializer,pypowsybl.voltage_initializer.impl.voltage_initializer_results)
      \-report (pypowsybl.loadflow.impl.loadflow,pypowsybl.network.impl.network,pypowsybl.network.impl.network_creation_util,pypowsybl.network.impl.network_element_modification_util,pypowsybl.report.impl.reporter,pypowsybl.security.impl.security,pypowsybl.sensitivity.impl.ac_sensitivity_analysis,pypowsybl.sensitivity.impl.dc_sensitivity_analysis,pypowsybl.shortcircuit.impl.short_circuit_analysis)
      \-security (pypowsybl.sensitivity.impl.sensitivity)
      \-utils (pypowsybl.dynamic.impl.model_mapping,pypowsybl.dynamic.impl.simulation_result,pypowsybl.flowdecomposition.impl.flowdecomposition,pypowsybl.glsk.impl.util,pypowsybl.loadflow.impl.loadflow,pypowsybl.network.impl.bus_breaker_topology,pypowsybl.network.impl.network,pypowsybl.network.impl.network_creation_util,pypowsybl.network.impl.network_element_modification_util,pypowsybl.network.impl.node_breaker_topology,pypowsybl.network.impl.util,pypowsybl.security.impl.security_analysis_result,pypowsybl.shortcircuit.impl.short_circuit_analysis,pypowsybl.shortcircuit.impl.short_circuit_analysis_result)



12985 lines have been analyzed

Raw metrics
-----------

+----------+-------+------+---------+-----------+
|type      |number |%     |previous |difference |
+==========+=======+======+=========+===========+
|code      |4404   |33.92 |4405     |-1.00      |
+----------+-------+------+---------+-----------+
|docstring |7064   |54.40 |7064     |=          |
+----------+-------+------+---------+-----------+
|comment   |503    |3.87  |504      |-1.00      |
+----------+-------+------+---------+-----------+
|empty     |1014   |7.81  |1014     |=          |
+----------+-------+------+---------+-----------+



Duplication
-----------

+-------------------------+------+---------+-----------+
|                         |now   |previous |difference |
+=========================+======+=========+===========+
|nb duplicated lines      |0     |0        |0          |
+-------------------------+------+---------+-----------+
|percent duplicated lines |0.000 |0.000    |=          |
+-------------------------+------+---------+-----------+



Messages by category
--------------------

+-----------+-------+---------+-----------+
|type       |number |previous |difference |
+===========+=======+=========+===========+
|convention |11     |2        |2          |
+-----------+-------+---------+-----------+
|refactor   |9      |5        |5          |
+-----------+-------+---------+-----------+
|warning    |5      |5        |5          |
+-----------+-------+---------+-----------+
|error      |7      |2        |2          |
+-----------+-------+---------+-----------+



Messages
--------

+-------------------------------+------------+
|message id                     |occurrences |
+===============================+============+
|used-before-assignment         |5           |
+-------------------------------+------------+
|wrong-import-order             |3           |
+-------------------------------+------------+
|duplicate-code                 |3           |
+-------------------------------+------------+
|consider-using-f-string        |3           |
+-------------------------------+------------+
|redefined-builtin              |2           |
+-------------------------------+------------+
|invalid-repr-returned          |2           |
+-------------------------------+------------+
|unused-variable                |1           |
+-------------------------------+------------+
|unnecessary-dunder-call        |1           |
+-------------------------------+------------+
|trailing-whitespace            |1           |
+-------------------------------+------------+
|trailing-newlines              |1           |
+-------------------------------+------------+
|too-many-public-methods        |1           |
+-------------------------------+------------+
|too-many-lines                 |1           |
+-------------------------------+------------+
|simplifiable-if-expression     |1           |
+-------------------------------+------------+
|no-else-return                 |1           |
+-------------------------------+------------+
|no-else-raise                  |1           |
+-------------------------------+------------+
|multiple-statements            |1           |
+-------------------------------+------------+
|inconsistent-return-statements |1           |
+-------------------------------+------------+
|fixme                          |1           |
+-------------------------------+------------+
|cyclic-import                  |1           |
+-------------------------------+------------+
|bad-chained-comparison         |1           |
+-------------------------------+------------+




------------------------------------------------------------------
Your code has been rated at 9.84/10

What is the new behavior (if this is a feature change)?

pytest: 0 warnings
pylint: 9.95/10

Does this PR introduce a breaking change or deprecate an API?

  • No

Signed-off-by: Damien Jeandemange <damien.jeandemange@artelys.com>
Signed-off-by: Damien Jeandemange <damien.jeandemange@artelys.com>
Signed-off-by: Damien Jeandemange <damien.jeandemange@artelys.com>
Signed-off-by: Damien Jeandemange <damien.jeandemange@artelys.com>
Comment on lines -105 to +109
columns_values.append(series.values)
if series.values.size and isinstance(series.values[0], np.bool_):
# to avoid DeprecationWarning: In future, it will be an error for 'np.bool_' scalars to be interpreted as an index
columns_values.append(series.values.astype(int))
else:
columns_values.append(series.values)
Copy link
Member Author

Choose a reason for hiding this comment

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

⚠️ to be double checked if this is correct, fixes

  /Users/runner/.local/lib/python3.8/site-packages/pypowsybl/utils/impl/dataframes.py:107: DeprecationWarning: In future, it will be an error for 'np.bool_' scalars to be interpreted as an index
    return _pp.create_dataframe(columns_values, columns_names, columns_types, is_index)

Copy link
Member

Choose a reason for hiding this comment

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

Looks ok to me. I spent some time looking at it a few monthes ago and never found the issue. But now looking at your fix, I understand. They just deprecated automatic conversion on numpy bool array to int array.

prettytable==2.0.0
prettytable==3.11.0 # last version supporting python 3.8
Copy link
Member Author

Choose a reason for hiding this comment

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

ℹ️ fixes these warning:

../../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/prettytable/__init__.py:1
  /Users/runner/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/prettytable/__init__.py:1: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    import pkg_resources

../../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/pkg_resources/__init__.py:3138
  /Users/runner/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/pkg_resources/__init__.py:3138: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('mpl_toolkits')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

../../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/pkg_resources/__init__.py:3138
../../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/pkg_resources/__init__.py:3138
../../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/pkg_resources/__init__.py:3138
../../../../hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/pkg_resources/__init__.py:3138
  /Users/runner/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/pkg_resources/__init__.py:3138: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('sphinxcontrib')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

data=[['GEN', '', 'OTHER', 6.07, -100, 49.99, -100, 100, None, 'MIN_MAX', 1.02, 3.01, True, 'GEN', -3.03,
data=[['GEN', '', 'OTHER', 6.07, -100, 49.99, -100, 100, nan, 'MIN_MAX', 1.02, 3.01, True, 'GEN', -3.03,
Copy link
Member Author

Choose a reason for hiding this comment

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

ℹ️

FutureWarning: Mismatched null-like values None and nan found. In a future version, pandas equality-testing functions (e.g. assert_frame_equal) will consider these not-matching and raise.
    pd.testing.assert_frame_equal(expected, n.get_generators(), check_dtype=False, atol=1e-2)

Copy link
Member

Choose a reason for hiding this comment

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

For another PR, but we should update our tests so that we don't need anymore check_dtype=False

@jeandemanged jeandemanged changed the title [WIP] Fix pytest and pylint warnings Fix pytest and pylint warnings Nov 7, 2024
Copy link

Copy link

@geofjamg geofjamg merged commit 9c6a0fa into main Nov 20, 2024
8 checks passed
@geofjamg geofjamg deleted the fix-warnings branch November 20, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants