Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Minor fixes #217

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix: Minor fixes #217

wants to merge 1 commit into from

Conversation

croyzor
Copy link
Collaborator

@croyzor croyzor commented May 17, 2024

I tried adding pyright to my environment instead of mypy, and it highlighted these issues!

@croyzor croyzor requested a review from mark-koch May 17, 2024 11:08
# Description of this definition to be used in messages to the user.
# The returned text should fit into messages of the following form: "expected
# a function, but got {description of this definition} instead".
description: str
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

N.B. in all of our subclasses of Definition, description is defined as a field

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does pyright complain about this? In the future we might have definitions where the description depends on the instance (for example if we unify struct and enum definitions into one class), so I would rather leave it more general

Copy link
Collaborator Author

@croyzor croyzor May 17, 2024

Choose a reason for hiding this comment

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

To be clear: the complaint is that the parent has property called description, and the subclasses are shadowing that name with a str field. I think to inherit properties the subclasses also need to look like:

class A(Definition):
    @property
    def definition() -> str:
        ...

but I could easily be wrong

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. The thing is that fields on frozen dataclasses are observably equivalent to get-only properties, so it's the same interface. But it looks like pyright doesn't recognise this...

It's confusing that we use the same pattern for TypeBase.linear but it's not complaining there?

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