wimglenn / pytest-structlog

Structured logging assertions
MIT License
56 stars 6 forks source link

Feature request: type hinting / mypy support #15

Closed meshy closed 9 months ago

meshy commented 3 years ago

Hi! Firstly, thank you for this useful pytest plugin.

I'm writing some code that uses mypy to do some reasonably strict type checking, and I've noticed that I get this error when importing from pytest_structlog:

error: Skipping analyzing 'pytest_structlog': found module but no type hints or library stubs

I can work around this by adding a block to my mypy.ini file:

[mypy-pytest_structlog.*]
ignore_missing_imports = True

Ideally however, it'd be nice if this project had type hinting. I notice that this project still has Python 2 in the TravisCI config, so it wouldn't be possible to use the Python 3 type annotations syntax, though there does appear to be mypy support for Python 2.

There's no important need for this, so no pressure! It's just a "nice to have" from my perspective :slightly_smiling_face:

wimglenn commented 3 years ago

Have you considered creating a stub file pytest_structlog.pyi?

meshy commented 3 years ago

That didn't occur to me. Good idea, thank you!

palfrey commented 9 months ago

So, making the stub file will work, but I wouldn't have thought this is actually closed? Would you be interested in a PR fixing this?

wimglenn commented 9 months ago

Okay, sure, with the caveat that the PR must also add a pyright or mypy run into the CI (i.e. in .github/workflows). I will reopen the issue.

palfrey commented 9 months ago

@wimglenn https://github.com/wimglenn/pytest-structlog/pull/27 does all that. Note that it doesn't work for 2.7 at all right now (but neither does the overall build), but wasn't sure of your thoughts on support there.