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

Type hints/stubs #352

Open
ethiy opened this issue Sep 27, 2022 · 8 comments
Open

Type hints/stubs #352

ethiy opened this issue Sep 27, 2022 · 8 comments

Comments

@ethiy
Copy link

ethiy commented Sep 27, 2022

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.

@seperman
Copy link
Owner

seperman commented Sep 27, 2022 via email

@ethiy
Copy link
Author

ethiy commented Oct 10, 2022

I think this article synthesizes very well the issue.

@seperman
Copy link
Owner

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.

@dpinol
Copy link

dpinol commented Oct 11, 2023

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

@sveinse
Copy link

sveinse commented Mar 27, 2024

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.

@rafrafek
Copy link

rafrafek commented Apr 4, 2024

how it could improve the user experience


This is what I see when using DeepDiff:

image

This is what I see when using Flask:

image

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.

@seperman
Copy link
Owner

seperman commented Apr 4, 2024

@rafrafek Is this a screenshot from your IDE? What IDE is that?

@rafrafek
Copy link

rafrafek commented Apr 4, 2024

@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 😅

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

5 participants