Skip to content

[pyright] Make transform and inference tip protocols positional-only - #3412

Open
Pierre-Sassoulas wants to merge 3 commits into
pylint-dev:mainfrom
Pierre-Sassoulas:pyright-transform-protocols
Open

Pierre-Sassoulas wants to merge 3 commits into
pylint-dev:mainfrom
Pierre-Sassoulas:pyright-transform-protocols

Conversation

@Pierre-Sassoulas

Copy link
Copy Markdown
Member

Type of Changes

Type
✓ 📜 Docs

Description

Transforms and inference tips are always called with positional arguments, but the protocols named their parameters, so any brain function whose parameter was called ctx instead of context, or that had no infer_function parameter, did not match. Inference tips are always given a context, so it no longer needs a default either.

This also fixes two annotations pyright then found: the PySide signal transform is registered for ClassDef, not FunctionDef, and the namedtuple base predicate returned a set instead of a bool.

@Pierre-Sassoulas Pierre-Sassoulas added Maintenance Discussion or action around maintaining astroid or the dev workflow Skip news 🔇 This change does not require a changelog entry labels Oct 19, 2026
@codspeed

codspeed Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 3 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing Pierre-Sassoulas:pyright-transform-protocols (d0b7b78) with main (5395efb)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩

@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.01%. Comparing base (5395efb) to head (d0b7b78).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3412   +/-   ##
=======================================
  Coverage   91.01%   91.01%           
=======================================
  Files          93       93           
  Lines       11800    11801    +1     
  Branches     1939     1939           
=======================================
+ Hits        10740    10741    +1     
  Misses        744      744           
  Partials      316      316           
Flag Coverage Δ
linux 90.69% <100.00%> (+<0.01%) ⬆️
pypy 91.01% <100.00%> (+<0.01%) ⬆️
windows 90.85% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
astroid/brain/brain_collections.py 100.00% <100.00%> (ø)
astroid/brain/brain_io.py 100.00% <100.00%> (ø)
astroid/brain/brain_pathlib.py 92.30% <100.00%> (+0.30%) ⬆️
astroid/brain/brain_qt.py 82.75% <100.00%> (ø)
astroid/typing.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Pierre-Sassoulas
Pierre-Sassoulas force-pushed the pyright-transform-protocols branch from df468f8 to 0861b9a Compare October 20, 2026 14:44
Transforms and inference tips are always called with positional
arguments, but the protocols named their parameters, so any brain
function whose parameter was called ctx instead of context, or that
had no infer_function parameter, did not match. Inference tips are
always given a context, so it no longer needs a default either.

This also fixes two annotations pyright then found: the PySide signal
transform is registered for ClassDef, not FunctionDef, and the
namedtuple base predicate returned a set instead of a bool.
The inference tip it registers now matches InferFn, which was the last
mypy error in the file.
Both files pass pyright now. mypy runs in strict mode and only asked
for the missing annotations. Once annotated, easy_class_getitem_inference
had to use _extract_single_node, since extract_node may return a list.
@Pierre-Sassoulas
Pierre-Sassoulas force-pushed the pyright-transform-protocols branch from 0861b9a to d0b7b78 Compare October 21, 2026 13:01

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

Maintenance Discussion or action around maintaining astroid or the dev workflow Skip news 🔇 This change does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant