Skip to content

Conversation

@dandavison
Copy link
Contributor

@dandavison dandavison commented Jul 12, 2025

This is PR 3/5 in a stack.

Fixes #12.

We use dataclass_transform to address the problem described in the issue, copied below.


Defining an operation in a service contract definition fails pyright's reportUninitializedInstanceVariable check with a message like

Instance variable "my_op" is not initialized in the class body or __init__ method

While this check is off by default in Pyright and Pylance (VSCode), it will be seen by users of Cursor and basedpyright unless they have disabled it.

Image

@dandavison dandavison changed the base branch from main to type-assertions July 12, 2025 20:24
@dandavison dandavison force-pushed the dataclass-transform branch from b91d87b to a9e11e7 Compare July 12, 2025 20:30
@dandavison dandavison force-pushed the dataclass-transform branch from a9e11e7 to fc753cf Compare July 12, 2025 20:38
@dandavison dandavison changed the title Dataclass transform [3/4] dataclass_transform Jul 12, 2025
@dandavison dandavison force-pushed the dataclass-transform branch from fc753cf to 4e78ff3 Compare July 12, 2025 20:54
@dandavison dandavison force-pushed the dataclass-transform branch from 4e78ff3 to f44be30 Compare July 12, 2025 21:31
@dandavison dandavison force-pushed the dataclass-transform branch from f44be30 to 47219c7 Compare July 12, 2025 21:45
@dandavison dandavison force-pushed the dataclass-transform branch from 47219c7 to 4af2252 Compare July 12, 2025 21:57
@dandavison dandavison force-pushed the dataclass-transform branch from 4af2252 to d461e2c Compare July 12, 2025 22:08
@dandavison dandavison force-pushed the dataclass-transform branch from d461e2c to 48b5b5c Compare July 12, 2025 22:28
@dandavison dandavison force-pushed the dataclass-transform branch from 48b5b5c to b65bae0 Compare July 13, 2025 16:25
@dandavison dandavison force-pushed the dataclass-transform branch from b65bae0 to 27110ec Compare July 13, 2025 18:50
@dandavison dandavison force-pushed the dataclass-transform branch from 27110ec to 4cd141d Compare July 14, 2025 13:04
@dandavison dandavison changed the title [3/4] dataclass_transform [3/5] dataclass_transform Jul 14, 2025
my_op: nexusrpc.Operation[None, None]

@service_handler(service=SD)
class SH:
Copy link

Choose a reason for hiding this comment

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

Are these reportUnusedClass and reportUnusedParameter issues valid? If not, we should consider disabling them for test due to noise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm still thinking about that. I'm tempted to make the codebase compliant, e.g. using underscore-prefixed variable names where they are intentionall not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've silenced all "unused thing" warnings at #18, and allowed pyright to fail if there are any warnings.

Copy link

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Looks like all of the warnings are addressed in another PR

AI: This commit should have tag name type-assertions and should be
force-pushed to a branch of that name as necessary.
AI: This commit should have tag name dataclass-transform and should be
force-pushed to a branch of that name as necessary.
@dandavison dandavison force-pushed the dataclass-transform branch from cb4777e to 9c06a2d Compare July 14, 2025 17:42
Base automatically changed from type-assertions to main July 14, 2025 19:11
@dandavison dandavison merged commit 79baa15 into main Jul 14, 2025
10 checks passed
@dandavison dandavison deleted the dataclass-transform branch July 14, 2025 19:13
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.

Operation definition in service definition triggers pyright's reportUninitializedInstanceVariable check

3 participants