Skip to content

fix: Replace print statements with logging and logging modular level (PR2) - #478

Draft
MoralCode wants to merge 4 commits into
mainfrom
PredictiveManish/libyear-util-update
Draft

MoralCode wants to merge 4 commits into
mainfrom
PredictiveManish/libyear-util-update

Conversation

@MoralCode

@MoralCode MoralCode commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Note

This PR was ported from augurlabs/augur#3648 filed by @PredictiveManish because the contribution was deemed to still be useful.

Description
This PR standardizes the logging implementation across libyear_util to follow Python best practices and solve #114:

Changes Made:

  1. Added module-level loggers: Each module now uses logger = logging.getLogger(__name__)
  2. Eliminated print statements: All console output now uses proper logging
  3. Fixed inconsistent patterns: Removed logger parameter passing in favor of module-level loggers
  4. Improved import organization: Removed duplicate imports

This PR partially solves #114

Notes for Reviewers

  • Consistent logging behavior across the codebase
  • Better control over log levels and output
  • Follows Python logging best practices
  • Easier debugging and monitoring
  • Cleaner separation of concerns

Testing

  • Enabled Python logging locally
  • Verified log messages emit via logger.info
  • No changes to control flow or task behavior
  • Verified logging output locally with logging.basicConfig(level=INFO).

Signed commits

  • Yes, I signed my commits.

Summary by CodeRabbit

  • Chores
    • Improved diagnostic logging during dependency parsing and libyear calculations.
    • Conda status messages are now recorded in logs rather than printed.



def get_release_date(data, version,logger):
def get_release_date(data, version, logger):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'logger' from outer scope (line 8) (redefined-outer-name)

@MoralCode

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

The dependency libyear utilities now log calculated day differences and parser diagnostics. Conda status messages use info-level logging instead of standard output. Parsing and libyear return behavior remain unchanged.

Changes: Dependency libyear logging

Layer / File(s) Summary
Libyear calculation logging
collectoss/tasks/git/dependency_libyear_tasks/libyear_util/pypi_libyear_util.py, collectoss/tasks/git/dependency_libyear_tasks/libyear_util/util.py
Both get_libyear functions log the day difference used in their existing calculations.
Dependency parser logging
collectoss/tasks/git/dependency_libyear_tasks/libyear_util/pypi_parser.py
Parsing diagnostics now use a module-level logger. Conda status messages use info-level logging instead of standard output. Parsing behavior is unchanged.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Merge Risk: Low · up to 5e600

The logging refactor is functionally safe, but the logger-parameter shadowing remains as a small maintainability and lint follow-up.

Architecture risk: Medium · up to 5e600

The change affects 1 system.

Changed systems: collectoss

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — collectoss (service) was modified; 3 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in collectoss/tasks/git/dependency_libyear_tasks/libyear_util/pypi_libyear_util.py: A module-level logger named logger is added.
  • observed — Modified behavior in collectoss/tasks/git/dependency_libyear_tasks/libyear_util/pypi_libyear_util.py: get_release_date’s parameter formatting changes; its parameters and behavior are unchanged.
  • observed — Modified behavior in collectoss/tasks/git/dependency_libyear_tasks/libyear_util/pypi_libyear_util.py: get_libyear now logs the day difference between the current and latest release dates before calculating and returning the same libyear value.
  • observed — Modified behavior in collectoss/tasks/git/dependency_libyear_tasks/libyear_util/pypi_parser.py: Adds the traceback import at the top of the module and initializes a module-level logger.

Reliability and maintainability

  • inferred — Risk-relevant change factors for collectoss: blast_radius_1; direct_dependents_1
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the main change: replacing print statements with logging across libyear_util, using module-level loggers. The raw summary shows the logger additions and print-to-logging changes in pyp…
Description check Passed The description follows the template's main sections: a summary of changes, a notes-for-reviewers section, a signed-commits checkbox, and testing notes. It explains the module-level logger change, the…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: replacing print statements with logging across libyear_util, using module-level loggers. The raw summary shows the logger additions and print-to-logging changes in pypi_parser.py, pypi_libyear_util.py, and util.py. The title says 'logging modular level', which is unclear wording for module-level loggers, and '(PR2)' is noise, but the title still reflects the primary change.

Full details: Description check

Explanation

The description follows the template's main sections: a summary of changes, a notes-for-reviewers section, a signed-commits checkbox, and testing notes. It explains the module-level logger change, the removal of print statements, and the removal of logger-parameter passing. Several template items are missing or incomplete. The 'This PR fixes #' line is unfilled, and the description says 'partially solves #114' without a clear issue reference. The Generative AI disclosure section is absent, and the author did not select an option. The 'Notes for Reviewers' items are generic benefits rather than review guidance. The description also omits the get_libyear logging change and the Conda info-level change. The description is mostly complete, so the check passes, but the author should fill in the missing items.

Resolution

Consider these improvements: (1) Add the issue reference in the 'This PR fixes #' line, or state that it partially addresses #114 and name the issue number. (2) Complete the Generative AI disclosure by selecting one option and, if AI tools were used, listing the tools, how they were used, and the review performed. (3) Replace the generic reviewer notes with specific guidance, such as which files changed and where reviewers should focus. (4) Consider correcting the title wording 'logging modular level' to describe module-level loggers.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 8 functions across 3 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ec3283bf-333e-4467-9c59-8f1f966296ce
Commits

Reviewing files that changed from the base of the PR and between 274301d and 5e60075.

Files selected for processing: 3
  • collectoss/tasks/git/dependency_libyear_tasks/libyear_util/pypi_libyear_util.py
  • collectoss/tasks/git/dependency_libyear_tasks/libyear_util/pypi_parser.py
  • collectoss/tasks/git/dependency_libyear_tasks/libyear_util/util.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

Signed-off-by: PredictiveManish <manish.tiwari.09@zohomail.in>
Signed-off-by: PredictiveManish <manish.tiwari.09@zohomail.in>
Signed-off-by: PredictiveManish <manish.tiwari.09@zohomail.in>
Added logger parameter to get_release_date function.

Signed-off-by: Manish Tiwari <manish.tiwari.09@zohomail.in>
@MoralCode
MoralCode force-pushed the PredictiveManish/libyear-util-update branch from 5e60075 to 1e3c5c2 Compare November 5, 2026 23:03
@@ -153,18 +152,18 @@ def parse_poetry(file_handle, repo_id=None, path=None):
try:
manifest = tomllib.load(file_handle)
except tomllib.TomlDecodeError as e:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
E1101: Module 'tomli' has no 'TomlDecodeError' member (no-member)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe we aliased the stdlib one....

@@ -153,18 +152,18 @@ def parse_poetry(file_handle, repo_id=None, path=None):
try:
manifest = tomllib.load(file_handle)
except tomllib.TomlDecodeError as e:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[pylint] reported by reviewdog 🐶
E1101: Module 'tomllib' has no 'TomlDecodeError' member (no-member)

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