-
Notifications
You must be signed in to change notification settings - Fork 60
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
Two mypy related issues #78
Comments
That was done by @trickeydan . I haven't used it. A PR to fix the first issue would be appreciated. For the second one, I think there's an annotation needed that tells the type checker it's not a normal type annotation. The type is actually determined by that annotation, but in a complicated way. I don't know if they support making that work. |
Thanks for the quick reply. Let me see if I can do the PR for point 1 and I'll do some digging on point 2 to see if there's a fix. |
That is expected because this library is hijacking the type system to specify the dbus signature.
You can do I have done some work designing an interface that does introspection from python type hints and generates the dbus signature, maybe we could integrate that here. |
If you're talking about converting Python types to DBUS types, that's a terrible idea because there is no clear relationship that way and you will end up confusing your users and making certain things impossible. For instance, Python If I wanted to do this the normal way, I would use decorators for the user to specify type strings. If the fancy decorators cannot be supported in the future, I'll go that way. |
All that can be supported with the type system, but supporting complex types such as containers explicitly would require PEP 646. See https://dbus-objects.readthedocs.io/en/latest/api.html#module-dbus_objects.types. As far as containers go, there is a pretty direct matching to python containers. Python lists are dbus arrays, python tuples are dbus structures, python dictionaries are dbus dictionaries, and dbus variants are If you don't want that direct mapping, with PEP 646 you will be able to do something like import dbus
def my_function(param: dbus.Array[dbus.Byte]) -> dbus.Structure[dbus.String, dbus.Int32]:
...
Well, given that we can let users do everything explicitly, I disagree. My implementation allows using native python containers, using the mapping I provided above, but that does not need to be the case, you can force them to use a notation like the one in the example.
Can you provide examples? |
I don't want to hijack this to talk about library design. If you want to continue the discussion, come to my discord chat (link in the readme) or start a new thread. |
I am in the discord, same nick, if you want to reply there feel free to ping me. |
I've got two issues related to mypy:
py.typed
file is not included in the pip package so mypy reports errors likeSkipping analyzing 'dbus_next.service': found module but no type hints or library stubs
py.typed
file, those errors disappear but I still get messages likeerror: Name 's' is not defined
when defining service methods etc.Have I missed something on the second one that's making mypy fail?
The text was updated successfully, but these errors were encountered: