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

Improve annotation of fromstring #64

Merged
merged 5 commits into from
Jul 26, 2022

Commits on May 3, 2022

  1. Improve annotation of fromstring

    `parser` seems like it can be an `HTMLParser. There's code in the wild
    that does this without obviously being wrong. As far as I can tell from
    the lxml Cython source, `parser` is a `_Baseparser`. I wasn't sure if
    the `iterparse` class ought to be allowed here too. I erred on the side
    of caution.
    
    It's possible for this function to return None, if the parser has
    `recover=True`. I couldn't find a good way to express this without
    affecting every other call to `fromstring`. (Perhaps one could make the
    Parser generic over some kind of `Recoverable` indicator type... but
    that seemed like overkill)
    
    Resolves lxml#63.
    DMRobertson committed May 3, 2022
    Configuration menu
    Copy the full SHA
    8970d00 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fa254a2 View commit details
    Browse the repository at this point in the history
  3. If no parse is specified, always return _Element

    This isn't strictly true: one can apparently change the default parser.
    But it's a nice refinement.
    DMRobertson committed May 3, 2022
    Configuration menu
    Copy the full SHA
    07ab5e7 View commit details
    Browse the repository at this point in the history
  4. Use _Element | Any instead of _Element | None

    so as to not burden existing users with having to check the None-ness of
    `fromstring()` return values
    DMRobertson committed May 3, 2022
    Configuration menu
    Copy the full SHA
    547e325 View commit details
    Browse the repository at this point in the history

Commits on May 6, 2022

  1. parse should return _ElementTree | Any.

    Co-authored-by: scoder <[email protected]>
    DMRobertson and scoder authored May 6, 2022
    Configuration menu
    Copy the full SHA
    3aca181 View commit details
    Browse the repository at this point in the history