Skip to content

fix: use ty-native ignore syntax for add_cookies#394

Merged
stickerdaniel merged 1 commit into
mainfrom
fix/ty-cookie-ignore-syntax
Apr 28, 2026
Merged

fix: use ty-native ignore syntax for add_cookies#394
stickerdaniel merged 1 commit into
mainfrom
fix/ty-cookie-ignore-syntax

Conversation

@stickerdaniel
Copy link
Copy Markdown
Owner

@stickerdaniel stickerdaniel commented Apr 28, 2026

Summary

Replace # type: ignore[arg-type] (mypy syntax) with # ty: ignore[invalid-argument-type] (ty-native syntax) on the single suppression in core/browser.py. The mypy-style comment was inert under ty.

Why

The pending lockfile maintenance PR (#227) bumps ty to 0.0.33, which adds stricter checks. With the mypy-style # type: ignore[arg-type] comment that ty doesn't honor, ty 0.0.33 flags the BrowserContext.add_cookies(cookies) call as a dict[str, Any] vs Sequence[SetCookieParam] mismatch, breaking lint-and-check.

The mismatch is intentional and runtime-safe: cookies is a hand-built list of dicts loaded from JSON, and patchright validates the shape at runtime. Only the suppression syntax needs updating.

Test plan

  • Reproduced the failure: uvx --from 'ty==0.0.33' ty check linkedin_mcp_server/core/browser.pyerror[invalid-argument-type] before the fix.
  • Verified silent after fix on ty 0.0.33.
  • Verified ty 0.0.20 (currently pinned in main) still passes after fix — backwards-compatible with the current lock.
  • Full pytest passes locally on Python 3.13.13 — 389 passed in 5.11s.
  • pre-commit run passes (ruff, ruff-format, ty all green).
  • CI green on this PR.
  • After merge, re-rebase chore(deps): lock file maintenance #227 — its lint-and-check should pass.

`# type: ignore[arg-type]` is mypy syntax; ty does not honor it.
Newer ty versions (0.0.33+) flag the dict[str, Any] vs SetCookieParam
mismatch on `BrowserContext.add_cookies` even with the existing
ignore comment, breaking lint-and-check on the pending lockfile
maintenance PR (#227).

Switch to ty-native `# ty: ignore[invalid-argument-type]` placed on
the argument line where ty surfaces the diagnostic. Verified silent
on both ty 0.0.20 (current pin) and ty 0.0.33 (incoming via #227).
Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@stickerdaniel stickerdaniel marked this pull request as ready for review April 28, 2026 22:29
Copilot AI review requested due to automatic review settings April 28, 2026 22:29
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR updates a single type-checker suppression comment in core/browser.py from mypy syntax (# type: ignore[arg-type]) to ty-native syntax (# ty: ignore[invalid-argument-type]), making it effective under ty 0.0.33 which will be introduced by the pending lockfile PR (#227). The runtime behaviour is unchanged — no logic is modified.

Confidence Score: 5/5

Safe to merge — one-line comment change with no runtime impact.

The only change is swapping a type-checker suppression comment syntax; no logic, imports, or data flow are affected.

No files require special attention.

Important Files Changed

Filename Overview
linkedin_mcp_server/core/browser.py Replaced mypy-style # type: ignore[arg-type] with ty-native # ty: ignore[invalid-argument-type] on the add_cookies call; no logic change.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Load cookies from JSON file] --> B{li_at cookie present?}
    B -- No --> C[Return False]
    B -- Yes --> D["await context.add_cookies(cookies)\n# ty: ignore[invalid-argument-type]"]
    D --> E[Log import success]
    E --> F[Return True]
Loading

Reviews (1): Last reviewed commit: "fix: use ty-native ignore syntax for add..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the type-check suppression in import_cookies() to use ty’s native ignore comment syntax so the existing runtime-safe add_cookies(cookies) call remains accepted under newer ty versions.

Changes:

  • Replaced inert mypy-style # type: ignore[arg-type] with # ty: ignore[invalid-argument-type].
  • Adjusted formatting of the add_cookies call to attach the ty ignore to the argument line.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@stickerdaniel stickerdaniel merged commit 9d77ee5 into main Apr 28, 2026
10 checks passed
@stickerdaniel stickerdaniel deleted the fix/ty-cookie-ignore-syntax branch April 28, 2026 22:31
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