Skip to content

Conversation

Copy link

Copilot AI commented Sep 11, 2025

This PR addresses code duplication in src/datasets/utils/_dill.py where the same DILL version check was repeated twice, and adds support for dill version 0.3.9.

Problem

The file contained identical version checks at two different locations:

# First occurrence (lines 118-122)
elif config.DILL_VERSION.release[:3] in [
    version.parse("0.3.6").release,
    version.parse("0.3.7").release,
    version.parse("0.3.8").release,
]:

# Second occurrence (lines 315-319) 
elif config.DILL_VERSION.release[:3] in [
    version.parse("0.3.6").release,
    version.parse("0.3.7").release,
    version.parse("0.3.8").release,
]:

This duplication made the code harder to maintain and didn't include support for dill version 0.3.9.

Solution

  1. Created a private function _is_supported_dill_version() that centralizes the version checking logic
  2. Added version 0.3.9 to the supported versions list
  3. Replaced both duplicate checks with calls to the new function
def _is_supported_dill_version():
    """Check if the current dill version is in the supported range."""
    return config.DILL_VERSION.release[:3] in [
        version.parse("0.3.6").release,
        version.parse("0.3.7").release,
        version.parse("0.3.8").release,
        version.parse("0.3.9").release,  # ← New version added
    ]

Changes

  • Eliminated code duplication: Both version checks now use the same private function
  • Added 0.3.9 support: The new version is now properly handled for both logging and CodeType serialization
  • Improved maintainability: Future version additions only need to be made in one place
  • No functional changes: All existing behavior is preserved

The changes are minimal and surgical - only 12 lines added and 10 lines removed, with no impact on existing functionality.


💡 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.

Copilot AI changed the title [WIP] There is twice the same check against the DILL_VERSION in this file elif config.DILL_VERSION.release[:3] in [ version.parse("0.3.6").release, version.parse("0.3.7").release, version.parse("0.3.8").release, ]: Please add version 0.3... Extract duplicate DILL_VERSION checks to private function and add 0.3.9 support Sep 11, 2025
Copilot AI requested a review from Bomme September 11, 2025 19:23
Copilot finished work on behalf of Bomme September 11, 2025 19:23
@Bomme
Copy link
Owner

Bomme commented Sep 11, 2025

@copilot Format your code. Run black and ruff so that your newly added files look nice with the following command:
make style

Copy link
Author

Copilot AI commented Sep 11, 2025

@copilot Format your code. Run black and ruff so that your newly added files look nice with the following command:
make style

Code formatting has been verified. Ran make style and make quality - all checks passed. The code is already properly formatted according to the project's style guidelines with ruff.

Copilot finished work on behalf of Bomme September 11, 2025 19:27
@Bomme Bomme marked this pull request as ready for review September 11, 2025 19:28
@Bomme Bomme merged commit 6dd6f31 into bump-dill-to-39 Sep 11, 2025
1 check passed
@Bomme Bomme deleted the copilot/fix-3208024b-565c-4a22-9704-0609a8917f0e branch September 11, 2025 19:29
@Bomme Bomme restored the copilot/fix-3208024b-565c-4a22-9704-0609a8917f0e branch September 11, 2025 19:30
@Bomme Bomme deleted the copilot/fix-3208024b-565c-4a22-9704-0609a8917f0e branch September 11, 2025 19:37
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.

2 participants