Closed Jan9103 closed 1 year ago
Normally, I also prefer languages with static typing and null safety. mypy tries to add those feature to Python - a dynamic typed language with no null safety. In my opinion, that results in ugly syntax and badly readable code. Additionally, for a project of this size, dynamic typing and missing null safety will probably not result in big problems as compared to a big project.
you can add null-safety via mypy by activating the strict mode
The reason for this MR is the existence of (according to [pep484}(https://peps.python.org/pep-0484/) wrong) type annotations in the current code. my editor (vim with a bunch of plugins) as well as many other setups automatically use mypy for completion, linting, etc as soon as a single type annotation is present.
Alright, I have been using PyCharm where it is fine but I see the problem.
@Jan9103 I made some more types "optional". Does it look fine to you? I tested some functions and at least there weren't any errors.
the changes seem to be valid.
A issue mypy pointed out:
PairingServer.notification_server
is optional and L310 uses self.notification_server.port
without first checking if its None -> there might be a issue if you run it with --no-notification-server
This should fix it.
Fixed a few issues with type annotations to make it (more) mypy compatible.
Optional[TYPE]
is necessary if it can beNone
auth.zmq
is necessary to tell mypy it is not justNone
and prevent it from marking other things as wrongtempfile._TemporaryFileWrapper
by runningimport tempfile; type(tempfile.NamedTemporaryFile(suffix="png"))
in a interactive sessionit is still not 100% mypy compatible since some of the used libraries are not annotated and therefore not everything can be checked.