-
Notifications
You must be signed in to change notification settings - Fork 28
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
Avoid "str | bytes" where names or text are meant #29
Comments
This is also relevant to |
The thing is, as long as users are still running their code in Py2, and writing code that works with Py2 and Py3, both need to be supported. Users who only target Py2 and not Py3 at all would probably also not use static type checkers, but legacy Py2/3 code should be supported. That said, yes, the current declarations are inconsistent. And the fact that legacy code needs to be supported doesn't mean that I think it's worth trying a switch to plain PR welcome. |
This seems to be changed in d95ca46 Issue can be closed in my opinion |
I changed the title to reflect the general issue here. |
It would break correctness on Python 2 because on Python 2 these attributes may return either str or unicode. Can we drop Python 2 compatibility of the typings? If yes, we can switch to If you want to keep Python 2 compatibility, we can use |
@matangover Agreed it's a good idea to drop py2 support for annotations. Personally I don't know anybody who's writing new code on py2 now, lest using annotation on py2 project. However, the removal of |
Agreed, |
Per python/typing#208 an instance of Python 2 |
The latest release of |
Right now
_Element.text
is typed asOptional[Union[str, bytes]]
. However according to the [lxml FAQ]:(https://lxml.de/3.6/FAQ.html):Having to deal with
bytes
makes all code accessing_Element.text
unnecessarily cumbersome.The text was updated successfully, but these errors were encountered: