Skip to content

Refactor config/plugin compatibility paths to Python 3.12 and remove legacy parsing duplication#2097

Closed
Copilot wants to merge 3 commits intov2.0.0from
copilot/fix-legacy-compatibility-issues
Closed

Refactor config/plugin compatibility paths to Python 3.12 and remove legacy parsing duplication#2097
Copilot wants to merge 3 commits intov2.0.0from
copilot/fix-legacy-compatibility-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 10, 2026

This change removes remaining legacy compatibility branches and anti-pattern typing around config/plugin loading. It centralizes config-file parsing through the core model path and aligns runtime behavior with the project’s Python 3.12 minimum.

All PR-Submissions:


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open
    Pull Requests for the same
    update/change?

New ✨✨ Feature-Submissions:


  • Does your submission pass tests?
  • Have you lint your code locally prior to submission? Fixed:
  • This PR is for a new feature, not a bug fix.

Changes to ⚙️ Core-Features:


  • Have you added an explanation of what your changes do and why you'd like
    us to include them?

  • Have you written new tests for your core changes, as applicable?

  • Have you successfully run tests with your changes locally?

  • Problem addressed

    • Remaining anti-patterns: untyped legacy bridges (Any/casts), duplicated core vs Jupyter parsing paths, and Python <3.12 compatibility code still present in active paths.
  • Core changes

    • Python 3.12 standardization
      • Replaced tomli reads with stdlib tomllib in:
        • spectrafit/core/fitting_config.py
        • spectrafit/cli/commands/convert.py
        • spectrafit/models/project_config.py
      • Removed tomllib/tomli import fallback branches in Jupyter config loading and corresponding unit test path.
    • Eliminated core/Jupyter parsing duplication
      • spectrafit/jupyter/config_io.py::load_notebook_config() now validates through UnifiedFittingConfig.from_file(...) instead of re-implementing file parsing.
    • Removed plugin discovery anti-pattern
      • spectrafit/plugins/discovery.py now uses entry_points().select(...) directly; removed cast("Any", ...), plugins_eps: Any, and old-version branching.
    • Focused regression coverage
      • Added tests/unit/test_plugin_discovery.py for entry_points().select(...) discovery behavior.
      • Updated tests/unit/test_jupyter_roundtrip.py to use tomllib directly.
  • Representative change

    # before (duplicated parser path in jupyter/config_io.py)
    if src.suffix == ".toml":
        raw = tomllib.load(fh)
    elif src.suffix == ".json":
        raw = json.load(fh)
    return UnifiedFittingConfig.model_validate(raw)
    
    # after (single core parser/validator path)
    if src.suffix not in {".toml", ".json"}:
        raise ValueError(...)
    return UnifiedFittingConfig.from_file(src)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com bot commented Mar 10, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  spectrafit/plugins/discovery.py  30% smaller
  tests/unit/test_jupyter_roundtrip.py  23% smaller
  spectrafit/jupyter/config_io.py  10% smaller
  spectrafit/cli/commands/convert.py  0% smaller
  spectrafit/core/fitting_config.py  0% smaller
  spectrafit/models/project_config.py  0% smaller
  tests/unit/test_plugin_discovery.py  0% smaller

Co-authored-by: Anselmoo <13209783+Anselmoo@users.noreply.github.com>
Co-authored-by: Anselmoo <13209783+Anselmoo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix legacy compatibility and transformation issues for Python 3.12 Refactor config/plugin compatibility paths to Python 3.12 and remove legacy parsing duplication Mar 10, 2026
@sonarqubecloud
Copy link
Copy Markdown

@github-actions github-actions bot added the python Pull requests that update Python code label Mar 11, 2026
@stale
Copy link
Copy Markdown

stale bot commented Mar 26, 2026

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Mar 26, 2026
@stale stale bot closed this Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests that update Python code size/L wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants