Open ethiy opened 2 years ago
Can you please give me an example of how type hints help the developers in using the library? I understand if they were contributing code but not very clear to me how it could improve the user experience. Thanks,
Sep Dehpour
On Sep 27, 2022, at 11:19 AM, Oussama ENNAFII @.***> wrote:
It would be really helpful to have type hints or stubs for this package to help the developer in his experience using the library*.
I have found no alternative solution, for now.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.
Ok that article needs a subscription to "real Python". Since the type hints don't cause any performance improvement in cPython, we don't have it as a priority task. We can add the type hints to the new functions though.
Type hints are extremely useful for discovering functions, arguments... and also for detecting regressions https://www.infoworld.com/article/3630372/get-started-with-python-type-hints.html
Type annotations are a very useful tool to improve code quality. It helps in describing the expected behavior and help the developers write more accurate code. Especially when paired with an IDE that analyse type annotations while coding. Many python projects requires type annotations these days. All type annotation-enabled projects using deepdiff
wil actually get a warning from mypy that deepdiff is missing library stubs. It would be very nice if this could be considered. Thanks.
edit As I'm looking at deepdiff internals to create a typing stub for my own use of deepdiff, I see that the job of type annotating deepdiff is going to be a considerable undertaking. The types of the various objects used are rather amorphous, which makes typing harder.
how it could improve the user experience
This is what I see when using DeepDiff:
This is what I see when using Flask:
The difference is that I don't know what an Unknown
is, but I know what a str
is. Or should I use list[str]
etc.
For me knowing the type helps. I don't need to look up the documentation so often to know what can I put as a parameter and what I can't.
@rafrafek Is this a screenshot from your IDE? What IDE is that?
@seperman Yes, it's from my IDE. It's VS Code with Python and Pylance extensions.
I'm using Pylance static type checker in "strict" mode. Strict mode may be too strict for existing projects, but I can recommend it for new ones. Pylance uses Pyright under the hood. Pyright can be used as a CLI tool or with pre-commit.
I'm using standard light theme with "sync with OS" option, so it switches to standard dark theme together with macOS after the sunset. I think most people use dark theme all the time so my IDE may look exotic even for VS Code users 😅
It would be really helpful to have type hints or stubs for this package to help the developer in his experience using the library*.
I have found no alternative solution, for now.