goldsmith / Wikipedia

A Pythonic wrapper for the Wikipedia API
https://wikipedia.readthedocs.org/
MIT License
2.89k stars 519 forks source link

fix issue #304 fallback for bad wikipedia.org title suggestion #305

Open hobson opened 2 years ago

hobson commented 2 years ago
wlerin commented 2 years ago

Not a contributor/maintainer, but that has way too many formatting changes to tell what you actually changed.

Edit: After some searching around and looking at the expected locations to be changed, I really don't see the point of this. The main problem isn't that suggestion sometimes (nearly always) returns bonkers "suggestions", it's that those take precedence over actual pages. A library that is meant to be incorporated into other programs (some of them non-interactive) spewing out a bunch of capital letters won't fix that.

theptrk commented 3 months ago

Someone should just make a PR that changes that priority.

Its right here: https://github.com/goldsmith/Wikipedia/blob/1554943e8ab463cef5e93081def48fafbdef324e/wikipedia/wikipedia.py#L272

    if auto_suggest:
      results, suggestion = search(title, results=1, suggestion=True)
      try:
        title = suggestion or results[0]
      except IndexError:
        # if there is no suggestion or search results, the page doesn't exist
        raise PageError(title)