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

mypy complains about Gtk.Template Call typing #202

Open
theCapypara opened this issue Dec 23, 2024 · 0 comments
Open

mypy complains about Gtk.Template Call typing #202

theCapypara opened this issue Dec 23, 2024 · 0 comments

Comments

@theCapypara
Copy link
Contributor

theCapypara commented Dec 23, 2024

In #187 Gtk.Template.Call was changed to be "generic". However this change breaks existing code with the mypy type checker for me:

@Gtk.Template
class Foo:
    bar = cast(Adw.ActionRow, Gtk.Template.Child())

This fails with:

error: Attribute function "Child" with type "Callable[[], Any]" does not accept self argument  [misc]

I think this isn't actually because of the Cast, but rather because the definition is wrong?

Shouldn't it be:

class Template:
    ...

    @classmethod
    def Child(cls) -> Any: ...

Note the cls. This fixes the issue for me.

mypy version: 1.13.0

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

No branches or pull requests

1 participant