Skip to content

refactor: code cleanup, dead code removal, and linting improvements#31

Merged
jarsarasty merged 1 commit intomainfrom
remove-unused-parameters
Mar 12, 2026
Merged

refactor: code cleanup, dead code removal, and linting improvements#31
jarsarasty merged 1 commit intomainfrom
remove-unused-parameters

Conversation

@jarsarasty
Copy link
Contributor

@jarsarasty jarsarasty commented Mar 5, 2026

  • Remove dead code (time_series_protocols.py, unused constants)
  • Extract shared helpers to eliminate duplication (BaseAdapter._parse_esdl_string,
    DatabaseTimeSeriesLoader._process_single_profile,
    TimeSeriesManager._load_xml_with_parameters/_load_xml_fallback)
  • Reduce cyclomatic complexity in EsdlAdapter._process_energy_system
  • Add ruff C9 (McCabe complexity) and ARG rules; refine per-file ignores
  • Add pylint to analysis dependency group
  • Rename run.py → check.py with optional --full pylint analysis
  • Rename KpiManager.get_esdl_with_kpis() → build_esdl_with_kpis()
  • Update architecture and implementation docs to reflect all changes

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR simplifies several internal/public method signatures by removing unused **kwargs parameters and marking unused placeholders with a leading underscore, and it cleans up unused constants.

Changes:

  • Remove **kwargs from exporter and adapter method signatures where not used.
  • Rename unused parameters (e.g., xml_time_series_dict_xml_time_series_dict, mesido_data_mesido_data) and update tests accordingly.
  • Remove unused constants from common/constants.py.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
unit_test/test_esdl_adapter.py Updates tests to match the _create_asset_from_esdl signature change.
src/kpicalculator/reporting/esdl_kpi_exporter.py Removes unused **kwargs/typing import from export() signature.
src/kpicalculator/reporting/base_exporter.py Removes **kwargs from the abstract export() signature.
src/kpicalculator/kpi_manager.py Renames unused mesido parameter to underscore-prefixed placeholder.
src/kpicalculator/common/constants.py Deletes unused constants.
src/kpicalculator/adapters/simulator_adapter.py Removes unused **kwargs from load_data().
src/kpicalculator/adapters/esdl_adapter.py Renames unused _create_asset_from_esdl parameter to underscore-prefixed name.
src/kpicalculator/adapters/base_adapter.py Narrows BaseAdapter.load_data() to only require source.
Comments suppressed due to low confidence (1)

src/kpicalculator/adapters/esdl_adapter.py:356

  • The parameter was renamed to _xml_time_series_dict, but the docstring Args: section still documents xml_time_series_dict. Update the docstring to match the new parameter name (and, if appropriate, note that it's intentionally unused/legacy).
        _xml_time_series_dict: PiXmlTimeSeries | None,
        model_name: str,
    ) -> Asset | None:
        """Create an Asset object from an ESDL element.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jarsarasty jarsarasty force-pushed the remove-unused-parameters branch from d7db4fd to 7eefe3b Compare March 5, 2026 14:50
@jarsarasty jarsarasty requested a review from Copilot March 5, 2026 14:50
Base automatically changed from feature/database-connectivity to main March 5, 2026 16:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jarsarasty jarsarasty force-pushed the remove-unused-parameters branch 2 times, most recently from 815bae9 to ce51c09 Compare March 6, 2026 11:03
@jarsarasty jarsarasty changed the title simplify method signatures and remove unused parameters refactor: code cleanup, dead code removal, and linting improvements Mar 6, 2026
@jarsarasty jarsarasty requested a review from Copilot March 6, 2026 11:05
@jarsarasty jarsarasty self-assigned this Mar 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 28 out of 29 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  - Remove dead code (time_series_protocols.py, unused constants)
  - Extract shared helpers to eliminate duplication (BaseAdapter._parse_esdl_string,
    DatabaseTimeSeriesLoader._process_single_profile,
    TimeSeriesManager._load_xml_with_parameters/_load_xml_fallback)
  - Reduce cyclomatic complexity in EsdlAdapter._process_energy_system
  - Add ruff C9 (McCabe complexity) and ARG rules; refine per-file ignores
  - Add pylint to analysis dependency group
  - Rename run.py → check.py with optional --full pylint analysis
  - Rename KpiManager.get_esdl_with_kpis() → build_esdl_with_kpis()
  - Update architecture and implementation docs to reflect all changes
@jarsarasty jarsarasty force-pushed the remove-unused-parameters branch from ce51c09 to 2bd14a0 Compare March 6, 2026 11:23
Copy link
Contributor

@MichielTukker MichielTukker left a comment

Choose a reason for hiding this comment

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

Maybe add version constraints in pyproject.toml

Comment on lines +35 to +49
analysis_rc |= _run(
[
"uv",
"run",
"pylint",
"src/",
"--disable=all",
"--enable=similarities,R0914,R0912,R0915",
"--min-similarity-lines=6",
"--max-locals=16",
# xml_time_series_adapter.py is testing-only and excluded from all linting
"--ignore=xml_time_series_adapter.py",
],
header="pylint — code analysis (duplicates, complexity, locals)",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why run pylint when the pyproject.toml contains a config for ruff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ruff handles most of the linting and style checks. However, it doesn't cover duplicate code detection or
too-many-locals/too-many-branches. The pylint invocation here is scoped to exactly those checks
(--enable=similarities,R0914,R0912,R0915), so it's complementary rather than redundant. It's also only run with check.py --full, so it doesn't affect the default pre-commit flow.

@jarsarasty
Copy link
Contributor Author

Maybe add version constraints in pyproject.toml

I think this comment may belong to the security updates PR (#32).. I will add the version constraints there.

@jarsarasty jarsarasty merged commit 3be15e2 into main Mar 12, 2026
8 checks passed
@jarsarasty jarsarasty deleted the remove-unused-parameters branch March 12, 2026 16:15
@jarsarasty jarsarasty restored the remove-unused-parameters branch March 12, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants