Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor(Init): make project_info a module and remove self.project_info #1605

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
bearomorphism wants to merge 1 commit into commitizen-tools:v4-9-2
base: v4-9-2
Choose a base branch
Loading
from bearomorphism:project-info-refactor

Conversation

Copy link
Contributor

@bearomorphism bearomorphism commented Sep 15, 2025

Description

Make project_info a module as ProjectInfo only contains stateless helpers.

Copy link

codecov bot commented Sep 15, 2025
edited
Loading

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v4-9-2@a472bea). Learn more about missing BASE report.

Additional details and impacted files
@@ Coverage Diff @@
## v4-9-2 #1605 +/- ##
=========================================
 Coverage ? 98.86% 
=========================================
 Files ? 59 
 Lines ? 2654 
 Branches ? 0 
=========================================
 Hits ? 2624 
 Misses ? 30 
 Partials ? 0 
Flag Coverage Δ
unittests 98.86% <100.00%> (?)

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.

Copy link
Contributor Author

Thanks for the quick review!

name: str = questionary.select(
"Please choose a supported config file: ",
choices=CONFIG_FILES,
default=default_path,
Copy link
Contributor Author

@bearomorphism bearomorphism Sep 15, 2025

Choose a reason for hiding this comment

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

The suffix path can sometimes refer to Path objects. I consider it less confusing with the suffix filename to indicate that it is a string.

@Lee-W Lee-W added this to the 4.9.2 milestone Sep 15, 2025
@Lee-W Lee-W changed the base branch from master to v4-9-2 September 15, 2025 15:35
class TestFileDetection:
"""Test file detection functions."""

def test_has_pyproject_when_file_exists(self, chdir):
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 we can use parameterize for these

Copy link
Contributor Author

@bearomorphism bearomorphism Sep 16, 2025
edited
Loading

Choose a reason for hiding this comment

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

Could you provide some details? I'm not sure how to make it more maintainable with parameterize.
Thanks 🙏

Comment on lines 24 to 27
def test_has_uv_lock_when_file_exists(self, chdir):
"""Test has_uv_lock returns True when uv.lock exists."""
Path("uv.lock").touch()
assert project_info.has_uv_lock() is True
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def test_has_uv_lock_when_file_exists(self, chdir):
"""Test has_uv_lock returns True when uv.lock exists."""
Path("uv.lock").touch()
assert project_info.has_uv_lock() is True
@pytest.mark.parameterzie("file_name, func_name", [("uv.lock", "has_uv_lock"), ...])
def test_return_true_when_file_exists(self, chdir, file_name: str, func_name: str):
"""Test has_uv_lock returns True when uv.lock exists."""
Path(file_name).touch()
assert getattr(project_info, "has_uv_lock")() is True

probably can try something like it

Copy link
Contributor Author

@bearomorphism bearomorphism Sep 18, 2025

Choose a reason for hiding this comment

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

Maybe it would be better if we just remove these simple has_XXX functions.

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 they're quite straightforward? Why do you think we should remove them

Copy link
Contributor Author

@bearomorphism bearomorphism Sep 18, 2025

Choose a reason for hiding this comment

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

Path(...).is_file() is also straightforward.

Copy link
Contributor Author

@bearomorphism bearomorphism Sep 18, 2025

Choose a reason for hiding this comment

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

I will update a commit later. I am still testing locally.

Copy link
Contributor Author

@bearomorphism bearomorphism Sep 18, 2025

Choose a reason for hiding this comment

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

Now both project_info.py and its test file are shorter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@Lee-W Lee-W Lee-W left review comments

@woile woile woile approved these changes

@noirbizarre noirbizarre Awaiting requested review from noirbizarre noirbizarre is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
4.10.0
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /