Skip to content

Fix for Property, add explicit hint for signal in notify argument #15

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

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

Conversation

kaneryu
Copy link

@kaneryu kaneryu commented Jul 4, 2025

No description provided.

@kaneryu
Copy link
Author

kaneryu commented Jul 4, 2025

I've been getting hundreds of these errors:

Argument "notify" to "Property" has incompatible type "Signal"; expected "Callable[..., Any] | None"mypy[arg-type](https://mypy.readthedocs.io/en/stable/_refs.html#code-arg-type)

(variable) urlChanged: Signal

image

And this fix resolves them.

@bluebird75
Copy link
Contributor

Hi,

Thanks for the contribution.

Could you also provide a simple example of failing code ?

@kaneryu
Copy link
Author

kaneryu commented Jul 6, 2025

Can you please clarify what you mean by failing?
In the example above, even though I am using the proper method to create a signal and assign it to the property, mypy is still giving me a type error. In my opinion, that is the example of failing code.

@matiaslina
Copy link

Hi! I'm experiencing this same issue.

Here is a minimal example that shows this error:

from PySide6.QtCore import QObject, Property, Signal


class Test(QObject):
    testChanged = Signal()

    def get_test(self) -> str:
        return 'test'

    def set_test(self, str) -> None:
        pass

    test = Property(str, get_test, set_test, notify=testChanged)
mypy t.py
t.py:13: error: Argument "notify" to "Property" has incompatible type "Signal"; expected "Callable[..., Any] | None"  [arg-type]
Found 1 error in 1 file (checked 1 source file)

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.

3 participants