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

#650 Add Type-Check to test #870

Closed

Conversation

kousikmitra
Copy link
Contributor

@kousikmitra kousikmitra commented Mar 22, 2020

This add type-check to tests

  • test_api.py
  • test_asgi.py

Refs #650

Copy link
Member

@florimondmanca florimondmanca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

It actually occurs to me that we're not running mypy on the tests folder yet. Ideally we'd need to add a new step to scripts/check for mypy tests/ with the appropriate options to silence any errors for files that aren't type-checked yet. Any ideas?

Comment on lines 74 to +77
@pytest.mark.asyncio
async def test_get_invalid_url(server):
async def test_get_invalid_url(server: Server) -> None:
with pytest.raises(httpx.InvalidURL):
await httpx.get("invalid://example.org")
await httpx.get("invalid://example.org") # type:ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so this entire test should really not be an async one — the high-level API is sync-only.

def test_post_byte_iterator(server):
def data():
def test_post_byte_iterator(server: Server) -> None:
def data() -> typing.Generator[bytes, None, None]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we prefer this more relaxed style, in line with our other typing usage in this repo?

Suggested change
def data() -> typing.Generator[bytes, None, None]:
def data() -> typing.Iterator[bytes]:

@florimondmanca
Copy link
Member

Hi there 👋 Going to close this for now as this has gone stale now, and there are some pending proposals to improve how we type check tests, cf #991… Thank you so much for putting time into this!

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

Successfully merging this pull request may close these issues.

2 participants