Skip to content

fix: use logger instead of print() in _agent_config.py - #3966

Open
Quratulain-bilal wants to merge 3 commits into
github:mainfrom
Quratulain-bilal:fix/agent-config-use-logger
Open

Quratulain-bilal wants to merge 3 commits into
github:mainfrom
Quratulain-bilal:fix/agent-config-use-logger

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

Problem

_agent_config.py used print(..., file=sys.stderr) for warnings instead of using the logging module.

Fix

Add logging.getLogger(name) and replace print() with logger.warning(). Remove unused sys import.

Replace print(..., file=sys.stderr) with logger.warning() for
consistent logging behavior. Removes unused sys import.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Replaces direct stderr warning output with module-level logging.

Changes:

  • Adds a module logger.
  • Replaces print(..., file=sys.stderr) with logger.warning().
  • Removes the unused sys import.
Show a summary per file
File Description
src/specify_cli/_agent_config.py Routes invalid integration warnings through logging.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread src/specify_cli/_agent_config.py

@mnriem mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Address Copilot feedback and fix test & lint errors

Quratulain-bilal added a commit to Quratulain-bilal/spec-kit that referenced this pull request Sep 1, 2026
Replace print(..., file=sys.stderr) with logger.warning() for consistent
logging behavior. Adds logging import and logger instance. Removes unused
sys import.

Adds regression test for invalid integration warning.

Closes github#3966
Verifies that invalid integration warnings use logger.warning()
instead of print() to stderr.

Addresses Copilot review feedback on github#3966.
@mnriem

mnriem commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

This is a logging-consistency change rather than a demonstrated functional fix, so we’re keeping it as triage-can-wait.

The specific test mismatch from the earlier review remains: test_resolve_default_init_integration_invalid_warns_and_falls_back still checks captured.err. Adding a separate caplog test does not update that existing assertion. Please address the named test as part of the change.

Please also state whether AI assistance was used and, if so, include the agent/tool, model, mode/settings, and extent of assistance.

Drafted for @mnriem with assistance from GitHub Copilot (model: GPT-6 Astra; interactive comment drafting).

@mnriem mnriem added triage-can-wait Verdict: valid and in-scope but deprioritized; held behind the evidence gate author-needs-disclosure AI use, or the agent/model/settings behind it, not disclosed per CONTRIBUTING author-awaiting Waiting on author response labels Sep 16, 2026
@mnriem
mnriem requested a balanced review from Copilot September 16, 2026 11:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

An existing stderr-based test will fail, and the docstring still incorrectly guarantees stderr output.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

src/specify_cli/_agent_config.py:46

  • The function docstring still promises that invalid values emit a warning to stderr, but logger.warning() routes output through configured logging handlers and does not guarantee stderr. Describe this as a logged warning so the public contract matches the implementation.
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +454 to +458
with caplog.at_level(logging.WARNING):
with patch.dict(os.environ, {"SPECKIT_INTEGRATION_DEFAULT": "nonexistent"}):
result = resolve_default_init_integration()
assert result == "copilot" # default fallback
assert any("nonexistent" in record.message for record in caplog.records)
@mnriem

mnriem commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback and fix test & lint errors

fix: update docstring to reflect logging module usage
@mnriem
mnriem self-requested a review September 23, 2026 18:47

This branch has not been deployed

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

Labels

author-awaiting Waiting on author response author-needs-disclosure AI use, or the agent/model/settings behind it, not disclosed per CONTRIBUTING triage-can-wait Verdict: valid and in-scope but deprioritized; held behind the evidence gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants