Skip to content

Conversation

@almarklein
Copy link
Member

Closes #783

@almarklein almarklein requested a review from Korijn as a code owner December 17, 2025 09:36
@almarklein almarklein merged commit e473816 into main Dec 17, 2025
19 checks passed
@almarklein almarklein deleted the safe-enum_int2str branch December 17, 2025 10:15
capabilities["usages"] = c_capabilities.usages

if c_capabilities.formats:
capabilities["formats"] = formats = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a side note on this syntax... the list mutability gets exploited here like a pointer. formats isn't used below this anymore... yet it still works.

I found this sorta confusing in python.

Copy link
Collaborator

@Korijn Korijn Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is pass by reference in python. It would be weird if capabilities["formats"] and formats were independent copies though right?

capabilities["formats"] = formats = [] is not short for:

capabilities["formats"] = []
formats = []

It's short for:

formats = []
capabilities["formats"] = formats

That's how I think about it at least.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this particular case the formats is indeed a temporary variable, to avoid the repetitive dict lookup for doing capabilities["formats"].append(str_val).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KeyError in _get_capabilities_screen

4 participants