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 stubs #1434

Closed
KotlinIsland opened this issue Aug 9, 2022 · 8 comments
Closed

type stubs #1434

KotlinIsland opened this issue Aug 9, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@KotlinIsland
Copy link
Contributor

I would like some type stubs for coverage, I see that you support >= 3.7 so types in the code would be possible (although perhaps not desirable).

I'm happy to drive this. just need to know if you want the stubs inline or in a separate package, or maybe even hosted on typehsed.

@KotlinIsland KotlinIsland added enhancement New feature or request needs triage labels Aug 9, 2022
@nedbat
Copy link
Owner

nedbat commented Aug 16, 2022

I'd be interested in adding annotations right into the code. I'd been using pycontracts as a pre-historic way of checking types, but that package is unmaintained and is causing pain.

If there are annotations, I want to run mypy, so we'd need some new tooling for that too.

@KotlinIsland
Copy link
Contributor Author

Sounds cool, I'll give it a shot and make a PR, would you be interested in basedmypy?

@KotlinIsland
Copy link
Contributor Author

KotlinIsland commented Aug 17, 2022

While I'm here should I implement black?

@nedbat
Copy link
Owner

nedbat commented Aug 17, 2022

That's generous of you, but I don't want black for this repo, thanks. I don't know anything about basedmypy, but I'm guessing I don't want that either, but maybe I'm wrong?

@KotlinIsland
Copy link
Contributor Author

KotlinIsland commented Aug 17, 2022

It's basically a fork of mypy with additional functionality.
basedmypy:

def foo(a=1)
    print(a)

mypy:

def foo(a: int = 1) -> None:
    print(a)

@andersk
Copy link
Contributor

andersk commented Aug 30, 2022

For projects that use coverage as a library (such as test runners), it would be better if the type annotations worked with standard mypy and didn’t require a custom fork.

@nedbat
Copy link
Owner

nedbat commented Jan 2, 2023

I've started adding annotations. About 3/4 of the coverage/*.py files now check cleanly. Please let me know if I should do something differently.

@KotlinIsland
Copy link
Contributor Author

@nedbat this is awesome! One outstanding task is to add a 'py.typed' file. See #1550

@nedbat nedbat closed this as completed Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants