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

Resolve typing complexity in tests and inventory #35

Open
davidverweij opened this issue Feb 5, 2021 · 0 comments
Open

Resolve typing complexity in tests and inventory #35

davidverweij opened this issue Feb 5, 2021 · 0 comments
Labels
bug Oh my

Comments

@davidverweij
Copy link
Member

Due to the unknown payloads from the inventory API, typing becomes more complex. As such, the response can return Any type:

async def response(path: str, params: str = None) -> Any

This is further complicated in tests with the use of a monkeypatch, e.g. in tests > consumer_tests > routers > conftest.py:

@pytest.fixture(scope="function")
    def response_row():
    ...

becomes something like

@pytest.fixture(scope="function")
    def response_row() -> Generator[Dict[str, Any], None, None]:
    ...

This however fails typing as unkown methods are called on the Generator (e.g. client.get()) - which is used with the monkeypatch. Not to mention the 'private' methods in those tests and the required typing for their returned values.

At this moment, I've resorted to exclude these tests from typing checks by mypy, i.e. in mypy.ini:

[mypy-consumer_tests.routers.conftest]
ignore_errors = True

[mypy-consumer_tests.routers.test_inventory]
ignore_errors = True

I've also excluded flake8 linting for error code AAA05 as it conflicts with black introducing a white line between private methods in an Act block.

Next steps

Ideally this typing is corrected to prevent any coding errors, but priority is low.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Oh my
Projects
None yet
Development

No branches or pull requests

1 participant