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-checking our tests #650

Closed
florimondmanca opened this issue Dec 19, 2019 · 6 comments · Fixed by #1054
Closed

Type-checking our tests #650

florimondmanca opened this issue Dec 19, 2019 · 6 comments · Fixed by #1054
Labels
good first issue Good for newcomers help wanted Extra attention is needed tooling Changes to our CI/CD, tests setup, etc.

Comments

@florimondmanca
Copy link
Member

I know this is not a standard thing to do across Encode projects, but I've been wondering if it would be worth starting to type-hint our tests.

I've seen at least two instances of this recently:

My rationale is based on two aspects:

  • It improves our upfront knowledge about how users will actually use HTTPX — currently their usage of type hints in the wild is not reflected anywhere.
  • It helps us catch type hint inconsistencies we wouldn't see in the core package.

The main counter-argument, I suppose, is that type hinting tests is tedious. I think that's fair, but I believe the two pro's above make it compelling.

Thoughts?

@florimondmanca florimondmanca added the tooling Changes to our CI/CD, tests setup, etc. label Dec 19, 2019
@florimondmanca
Copy link
Member Author

Alternatively, we could tweak the mypy config:

[mypy]
files = httpx, tests
ignore_missing_imports = True
disallow_untyped_defs = False
check_untyped_defs = True

[mypy-httpx]
disallow_untyped_defs = True
check_untyped_defs = False

Running this locally raises 141 errors, but mostly on internal APIs, so, hmm.

This was referenced Dec 20, 2019
@aalvrz
Copy link
Contributor

aalvrz commented Dec 23, 2019

I think this is a great idea, would like to work on this. Since I am pretty new to httpx, adding these type hints to the tests will give me a better picture of how httpx works under the hood.

@florimondmanca florimondmanca added the good first issue Good for newcomers label Dec 29, 2019
@florimondmanca
Copy link
Member Author

I think this is still a good idea, though it's a bit of busy work to upgrade our existing test code.

Let's perhaps just remind ourselves to add types whenever we add/touch existing tests?

@Pradhvan
Copy link

@florimondmanca I see a lot of merged PR. I guess you should close this ? 😄

@florimondmanca
Copy link
Member Author

I think there’s one small last step which would be to add tests/ to the mypy arguments in the check script. :-) Once this is enforced then yup, we can close this off.

@Pradhvan
Copy link

Pradhvan commented Jun 18, 2020

I am currently working on a different Good First Issue PR and when that is done. I would be happy to pick up what's remaining in this PR so we can close this one too. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed tooling Changes to our CI/CD, tests setup, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants