[Question] Is "REGISTRY" meant to be a decorator for "Collectors"?
Browsing through the code I've found a function called write_to_textfile in the exposition module. This function signature looks like this:
def write_to_textfile(path, registry):
"""Write metrics to the given path.
pass
If you read the implementation of the function, turns out the expectation is not really a registry but instead anything that implements (something like an interface) the .collect() method.
Is that by design?
If so, would it be welcomed the addition of type hints throughout the code? I would be happy to add them and create a PR.
It takes a registry, as the name clearly indicates.
Thanks @brian-brazil, you couldn't have been more clear. Does that mean adding the type hints is a welcomed addition?
What would that involve?
@migueleliasweb that would break compatibility with all python versions < 3.5
That's not on the cards then.
Hey @brian-brazil , adding the type hints would be just adding the specific type notations to the python files. That's quite handy as it would improve the autocomplete and hints from IDEs.
Some of the examples: https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html
@beregon87 That might be true. Which versions are you guys supporting atm?
I'm not a maintainer, but looking at setup.py:
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
That still looks to me like it'd break supported versions.
See #491 which tracks this issue - so I think this is duplicate. Note that as that task says, one can provide type hints without breaking backwards compatibility, by either using annotations in comments, or preferrably, by using type stubs( .pyi).
@paravoid I made a small PR illustrating that we can add types without breaking any compatibility. It passes all unit tests and adds enough type information so my code passes with running mypy with --strict.
I hope that could help to allow adding types. Here are some benefits, for people wondering if it is worth it:
- finds additional bugs that unit tests might not pick up
- enables autocompletion
- IDEs can refactor code without introducing bugs (this helps a lot with a large project)
- allows to compile module by mypyc to get a better performance