| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Thanks for contributing! I couldn't find any prior discussion about adding type hints directly to the package, but it does seem like preferred option, so I think it's worth opening an issue to suggest this idea to WebTest maintainers. |
Sorry, something went wrong.
Considering my PR to add my WebOb stubs as inline type hints to WebOb has been open for half a year without so much as a peep from a maintainer and them both being Pylons projects I decided not to bother spending the extra amount of time required to add inline hints, and I needed the stubs for something I was working on anyways, so it was quicker to just get it done. So since I already had them I decided to just contribute them. That being said, WebTest does have a different maintainer, which appears to be ever so slightly more active, so I'm willing to try: Pylons/webtest#271 |
Sorry, something went wrong.
There was a problem hiding this comment.
Considering that there has been no response upstream, it makes sense to me to add this typeshed.
Sorry, something went wrong.
| from webob.request import BaseRequest | ||
| from webtest.response import TestResponse | ||
|
|
||
| _Files: TypeAlias = Sequence[tuple[str, str] | tuple[str, str, bytes]] |
There was a problem hiding this comment.
Considering that Sequence is not a protocol, using a real protocol (from collections.abc or _typeshed) would be better.
Sorry, something went wrong.
There was a problem hiding this comment.
I considered using Collection, the minimum requirement appears to be Iterable & Sized at first glance, but since the docs and error message say list I wanted to be a little more conservative, in case some implementation details change, without making it annoying to pass in lists that contain a type that's compatible with tuple[str, str] | tuple[str, str, bytes].
Sorry, something went wrong.
| relative_to: str | None = None, | ||
| use_unicode: bool = True, | ||
| cookiejar: CookieJar | None = None, | ||
| parser_features: Sequence[str] | str | None = None, |
There was a problem hiding this comment.
See above. More instances below.
Sorry, something went wrong.
There was a problem hiding this comment.
This matches what beautifulsoup4 expects for the features parameter, so I think it should stay like this.
Sorry, something went wrong.
|
@srittau Are there any blockers left? I relaxed some of the remaining uses of Sequence to Collection or Iterable, where I felt it was safe, but the others should stay, as far as I'm concerned, since they more closely match the documented API or upstream use. |
Sorry, something went wrong.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Sorry, something went wrong.
There was a problem hiding this comment.
This looks fine for now, improvements can always be made later if necessary.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
A small testing framework for WSGI applications based around WebOb.
Source: https://github.com/Pylons/webtest/blob/3.0.6/webtest/__init__.py
Docs: https://docs.pylonsproject.org/projects/webtest/en/latest/
webtest.forms.Form turned out a little more lax than I would've liked. But making it more strict would've probably caused quite a bit of churn in test code, like not being able to use Checkbox.checked without first doing an isinstance check, or either having to do the same for Select.select/MultipleSelect.select_multiple or having to switch to Form.select/Form.select_multiple.
I also debated for a while on whether or not to make TestApp generic, but ultimately it seemed worth it, since if you have a test fixture that returns a TestApp, you don't necessarily want to have to specify another fixture in order to get at the WSGIApplication that's being tested with the correct type information. Giving the TypeVar a default of WSGIApplication should end up making it behave more or less the same as the non-generic version, if you don't care about being able to access the application through TestApp.app.