Skip to content

[pyxdg] Menu and icon lookups can return None - #16881

Open
hnwg wants to merge 1 commit into
python:mainfrom
hnwg:pyxdg-lookups-can-return-none
Open

hnwg wants to merge 1 commit into
python:mainfrom
hnwg:pyxdg-lookups-can-return-none

Conversation

@hnwg

@hnwg hnwg commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Menu.getMenu(), Menu.getMenuEntry() and getIconPath() will return None if no matching submenus/entries/icons are found. getIconData() returns None if there is no .icon file (it's documented in the docstring).

>>> from xdg.Menu import Menu
>>> print(Menu().getMenu("Office"))
None

getMenuEntry() compares the given value to MenuEntry.DesktopFileID, which is already a str in the stubs, therefore this parameter must be a str, not an int.

Menu.getMenu(), Menu.getMenuEntry(), getIconPath() and getIconData()
return None when nothing matches. getMenuEntry() compares its argument
with MenuEntry.DesktopFileID, so the parameter is str, not int.
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant