Skip to content

refactor(BaseConfig): update function name, upgrade mypy version #1444

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bearomorphism
Copy link
Contributor

Description

Checklist

Code Changes

  • Add test cases to all the changes you introduce
  • Run poetry all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

  • Run poetry doc locally to ensure the documentation pages renders correctly

Expected Behavior

Steps to Test This Pull Request

Additional Context

Comment on lines -33 to -35
def add_path(self, path: str | Path) -> None:
self._path = Path(path)

Copy link
Contributor Author

@bearomorphism bearomorphism May 20, 2025

Choose a reason for hiding this comment

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

I just found this method name confusing. It's actually updating the path, right?

Copy link
Member

Choose a reason for hiding this comment

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

I think the main reason we make it this way is that we want to handle both str and Path implicitly. We probably could use a setter if that's better

Copy link
Contributor Author

@bearomorphism bearomorphism May 20, 2025

Choose a reason for hiding this comment

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

OK I was trying the following

    @property
    def path(self) -> Path | None:
        return self._path

    @path.setter
    def path(self, path: str | Path) -> None:
        self._path = Path(path)

but mypy isn't happy

commitizen/config/yaml_config.py:17: error: Incompatible types in assignment (expression has type "Path | str", variable has type "Path | None")  [assignment]
commitizen/config/toml_config.py:17: error: Incompatible types in assignment (expression has type "Path | str", variable has type "Path | None")  [assignment]
commitizen/config/json_config.py:16: error: Incompatible types in assignment (expression has type "Path | str", variable has type "Path | None")  [assignment]

I'm taking a look at related issues and PRs. Updating mypy to 1.15.0 does not work for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like python/mypy#18510 will be part of 1.16.

Copy link

codecov bot commented May 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.57%. Comparing base (120d514) to head (117e61c).
Report is 619 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1444      +/-   ##
==========================================
+ Coverage   97.33%   97.57%   +0.23%     
==========================================
  Files          42       57      +15     
  Lines        2104     2682     +578     
==========================================
+ Hits         2048     2617     +569     
- Misses         56       65       +9     
Flag Coverage Δ
unittests 97.57% <100.00%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bearomorphism bearomorphism force-pushed the refactor-config branch 4 times, most recently from 5aaad88 to 313143d Compare May 20, 2025 15:41
@bearomorphism bearomorphism force-pushed the refactor-config branch 2 times, most recently from cca754e to 45fe774 Compare May 20, 2025 15:48
@bearomorphism bearomorphism changed the title refactor(BaseConfig): remove path property refactor(BaseConfig): update function name May 20, 2025
@bearomorphism bearomorphism changed the title refactor(BaseConfig): update function name refactor(BaseConfig): update function name, upgrade mypy version May 20, 2025
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.

2 participants