Skip to content

Conversation

@dangotbanned
Copy link
Contributor

@dangotbanned dangotbanned commented Apr 12, 2025

scalar.pyi:281:5 - error: Overload 3 for "scalar" overlaps overload 4 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:281:5 - error: Overload 3 for "scalar" overlaps overload 5 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:297:5 - error: Overload 7 for "scalar" overlaps overload 8 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:313:5 - error: Overload 11 for "scalar" overlaps overload 16 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:313:5 - error: Overload 11 for "scalar" overlaps overload 17 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:313:5 - error: Overload 11 for "scalar" overlaps overload 26 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:327:5 - error: Overload 13 for "scalar" overlaps overload 14 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:327:5 - error: Overload 13 for "scalar" overlaps overload 15 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:327:5 - error: Overload 13 for "scalar" overlaps overload 18 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:327:5 - error: Overload 13 for "scalar" overlaps overload 19 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:327:5 - error: Overload 13 for "scalar" overlaps overload 20 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:327:5 - error: Overload 13 for "scalar" overlaps overload 21 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:327:5 - error: Overload 13 for "scalar" overlaps overload 22 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:327:5 - error: Overload 13 for "scalar" overlaps overload 23 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:327:5 - error: Overload 13 for "scalar" overlaps overload 24 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:327:5 - error: Overload 13 for "scalar" overlaps overload 25 and returns an incompatible type (reportOverlappingOverload)
scalar.pyi:369:5 - error: Overload 19 for "scalar" will never be used because its parameters overlap overload 18 (reportOverlappingOverload)
scalar.pyi:376:5 - error: Overload 20 for "scalar" will never be used because its parameters overlap overload 18 (reportOverlappingOverload)

Example of flaky false-negative

Mentioned in

Loading a module for the first time fails to match an overload

image

Editing the file (e.g. adding a space) "fixes" the issue

image

- Avoid 18 warnings from `pyright`
- very similar to zen-xu#183
- `MonthDayNano` was a bit tricky, but is based on https://github.com/python/typeshed/blob/a045be8ed62492952595661118af22554c7cbca4/stdlib/_typeshed/__init__.pyi#L316-L333
  - Had to rewrite manually to avoid overload overlaps on `CollectionValue`
  - Has all the properties/members returns by `inspect.getmembers`
  - Signature via `inspect.signature`
@zen-xu
Copy link
Owner

zen-xu commented Apr 22, 2025

Can you give an example?

@dangotbanned
Copy link
Contributor Author

Can you give an example?

@zen-xu I'm not sure I understand correctly, so apologies if this is the wrong part.

Example 1

The example I gave comes from https://github.com/narwhals-dev/narwhals/blob/9d44834321c6cdeecb902f3a41742669a2156cc5/narwhals/_arrow/series.py#L1100

But as I mentioned in (#219 (comment)), this issue can show up anywhere pa.scalar or pa.array are used without a type argument provided.

Example in description

Example of flaky false-negative

Mentioned in

Loading a module for the first time fails to match an overload

image

Editing the file (e.g. adding a space) "fixes" the issue

image

Example 2

This was the most minimal repro I could do for the performance issue (ignoring my initial typo 😄)

2025-04-22.10-23-20.-.scalar.mp4

Specs

I've not had performance issues from stubs before - but just to verify - I don't think I'm pushing my PC too far here

pyproject.toml Outdated
Comment on lines 51 to 52
mypy = ">=1.15"
ruff = ">=0.11.5"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI, if any merge conflicts pop up in the future - this change is most likely the source.
I needed to bump ruff to get a fix in CI that was required by pre-commit.

@zen-xu
Copy link
Owner

zen-xu commented May 9, 2025

Example 2 did not reproduce on my Mac

  • pylance: 2024.8.1
  • vscode: 1.96.2
  • pyright type checking mode: basic

@dangotbanned
Copy link
Contributor Author

Example 2 did not reproduce on my Mac

* pylance: 2024.8.1

* vscode: 1.96.2

* pyright type checking mode: basic

@zen-xu could you try a more recent pylance release?

The version you're using seems to be from 8 months ago - which would be before I started using pyarrow-stubs

@dangotbanned
Copy link
Contributor Author

dangotbanned commented May 9, 2025

Oh for the second example, it is important to have these settings enabled

"python.analysis.inlayHints.functionReturnTypes": true,
"python.analysis.inlayHints.variableTypes": true,

@zen-xu
Copy link
Owner

zen-xu commented May 14, 2025

I think #233 has resolved this problem

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