jayvdb added a comment.

Worth noting that this `KeyError` is a breaking change from compat, so this 
isnt an unreasonable request.

compat raised ValueError when one of the `namespaces` was a string and it was 
not a valid namespace.  However no exception was raised when an integer was 
provided but wasnt a valid namespace.

The new core interface 
(https://phabricator.wikimedia.org/rPWBC21a6732e8600bed030fdd45298e7d76a6bde9911)
 always raises `KeyError` for an invalid namespace, irrespective of whether it 
was a string or integer.

This interface is now implemented across the codebase in a very consistent 
manner, and it isnt simple to provide a different interface for 
`NamespaceFilterPageGenerator`.

Irrespective of whether `NamespaceFilterPageGenerator` is modified, a 
permissive namespace lookup method in `NamespaceDict` seems like it will be 
useful.  It would accept a list of namespace identifiers and returned a 
filtered list of the namespaces that are valid on the site.

Also possible: the `KeyError` raised by `NamespaceDict.resolve` could be a 
custom `KeyError` subclass, which contains two attributes: valid and invalid 
namespaces, so the caller can decide what needs to be done.   
`NamespaceFilterPageGenerator` could then proceed with only the valid 
namespaces, after issuing warnings for the invalid namespaces.


TASK DETAIL
  https://phabricator.wikimedia.org/T110388

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: jayvdb
Cc: jayvdb, XZise, Mpaa, Aklapper, Multichill, JeanFred, pywikibot-bugs-list, 
Malyacko



_______________________________________________
pywikibot-bugs mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to