Skip to content

fix(deps): update YAML import statements and add types-PyYAML to dev …#2761

Merged
Devesh36 merged 1 commit into
Tracer-Cloud:mainfrom
ApexYash11:v1
Jun 6, 2026
Merged

fix(deps): update YAML import statements and add types-PyYAML to dev …#2761
Devesh36 merged 1 commit into
Tracer-Cloud:mainfrom
ApexYash11:v1

Conversation

@ApexYash11

Copy link
Copy Markdown
Contributor

…dependencies

Fixes #
chore(deps): add types-PyYAML stubs and remove yaml type ignores (#2590)

Describe the changes you have made in this PR -

Added types-PyYAML>=6.0.12 to the [dependency-groups] dev list in pyproject.toml and removed three # type: ignore[import-untyped] comments from import yaml lines in app/cli/commands/config.py. With the stubs installed, mypy can now fully type-check all yaml usage without suppressions

Demo/Screenshot for feature changes and bug fixes -

Screenshot 2026-06-05 214611

Code Understanding and AI Usage

Did you use AI assistance (ChatGPT, Claude, Copilot, etc.) to write any part of this code?

  • No, I wrote all the code myself
  • Yes, I used AI assistance (continue below)

If you used AI assistance:

  • I have reviewed every single line of the AI-generated code
  • I can explain the purpose and logic of each function/component I added
  • I have tested edge cases and understand how the code handles them
  • I have modified the AI output to follow this project's coding standards and conventions

Explain your implementation approach:

What problem does your code solve?
The project uses import yaml in three places (app/cli/commands/config.py), but PyYAML doesn't ship inline type annotations. This required # type: ignore[import-untyped] on every import, suppressing mypy checks and weakening type coverage. Any misuses of the yaml API (wrong arguments, wrong return types) would go undetected

What alternative approaches did you consider?

  1. Inline type stubs — writing a local yaml.pyi stub. This would need maintenance as PyYAML evolves.
  2. Keeping the ignores — status quo, but leaves the type hole open.
  3. Using a typed wrapper — wrapping yaml.safe_load/yaml.safe_dump in typed helper functions. Over-engineered for the problem

Why did you choose this specific implementation?
The types-PyYAML package from typeshed is the canonical solution — it's the same approach already used for types-psutil. It requires zero new code, zero behavioral changes, and is maintained by the community alongside CPython releases. Adding it to [dependency-groups] dev keeps it scoped to development (not runtime). The type: ignore comments were then removable in one clean sweep

What are the key functions/components and what do they do?

  • pyproject.toml [dependency-groups] dev — declares types-PyYAML>=6.0.12 as a dev-only dependency, installed by uv sync --extra dev.
  • app/cli/commands/config.py lines 88, 105, 167 — three import yaml statements. Removing the # type: ignore[import-untyped] lets mypy resolve yaml.safe_load, yaml.safe_dump etc. against the stubs and catch real type errors.

Checklist before requesting a review

  • I have added proper PR title and linked to the issue
  • I have performed a self-review of my code
  • I can explain the purpose of every function, class, and logic block I added
  • I understand why my changes work and have tested them thoroughly
  • I have considered potential edge cases and how my code handles them
  • If it is a core feature, I have added thorough tests
  • My code follows the project's style guidelines and conventions

Note: Please check Allow edits from maintainers if you would like us to assist in the PR.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Greptile code review

This repo uses Greptile for automated review. Before merge, aim for Confidence Score: 5/5 with zero unresolved review threads — see CONTRIBUTING.md.

Run a review — add a PR comment with:

@greptile review

Give it ~5-10 minutes (sometimes longer) for results, then fix feedback and re-trigger until you reach Confidence Score: 5/5.

Optional: automate with the greploop skill.

@greptile-apps

greptile-apps Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds types-PyYAML>=6.0.12 to the dev dependency group in pyproject.toml and removes three # type: ignore[import-untyped] suppressions from import yaml statements in app/cli/commands/config.py, enabling full mypy coverage of PyYAML usage.

  • pyproject.toml / uv.lock: types-PyYAML is added as a dev-only dependency; the lockfile resolves it to 6.0.12.20260510, which satisfies the >=6.0.12 constraint. The package was already present in the lockfile as a transitive dependency, so this just makes it explicit.
  • app/cli/commands/config.py: The three # type: ignore[import-untyped] comments are removed from lazy import yaml statements inside _load_config, _save_config, and config_show — a purely cosmetic/type-hygiene change with no runtime effect.

Confidence Score: 5/5

Safe to merge — no logic changes, only type stub addition and suppression comment removal.

All three changed files are straightforward: the lockfile correctly resolves the new stub package, pyproject.toml follows the existing types-psutil pattern exactly, and the config.py edits are purely cosmetic removals of now-unnecessary suppression comments with zero runtime impact.

No files require special attention.

Important Files Changed

Filename Overview
app/cli/commands/config.py Removed three # type: ignore[import-untyped] comments from lazy import yaml statements — no logic changes, purely type-hygiene cleanup.
pyproject.toml Added types-PyYAML>=6.0.12 to the [dependency-groups] dev list, matching the same pattern used for types-psutil.
uv.lock Lock file updated to resolve types-pyyaml at 6.0.12.20260510 in dev metadata; the package entry itself was already present as a transitive dependency.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[mypy type check] --> B{PyYAML stubs available?}
    B -- "Before PR: No" --> C["# type: ignore[import-untyped] required"]
    B -- "After PR: Yes (types-PyYAML)" --> D[Full type resolution of yaml.*]
    D --> E[yaml.safe_load / yaml.safe_dump fully checked]
    C --> F[yaml API misuse goes undetected]
Loading

Reviews (1): Last reviewed commit: "fix(deps): update YAML import statements..." | Re-trigger Greptile

@Devesh36 Devesh36 merged commit 1a32f72 into Tracer-Cloud:main Jun 6, 2026
15 checks passed
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

🎊 Achievement unlocked: PR Merged. @ApexYash11 passed code review, survived CI, and shipped. Respect. 🤝


👋 Join us on Discord - OpenSRE : hang out, contribute, or hunt for features and issues. Everyone's welcome.

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