Skip to content

fixes in order to support NetworkManager#204

Closed
j-baker wants to merge 1 commit intopygobject:masterfrom
j-baker:jbaker/nm
Closed

fixes in order to support NetworkManager#204
j-baker wants to merge 1 commit intopygobject:masterfrom
j-baker:jbaker/nm

Conversation

@j-baker
Copy link

@j-baker j-baker commented Feb 23, 2025

I wanted to generate stubs using this tool for NetworkManager (NM).

What I found was failures for two reasons:

  1. Cannot generate due to invalid identifiers (80211Flags).
  2. Some enums with no entries.

I fixed this by:

  1. Quoting those identifiers. My belief is that this will keep mypy working but fixing the python level issues.
  2. Printing pass after each enum with empty entries.

I wanted to generate stubs using this tool for NetworkManager (NM).

What I found was failures for two reasons:

1. Cannot generate due to invalid identifiers (80211Flags).
1. Some enums with no entries.

I fixed this by:

1. Quoting those identifiers. My belief is that this will keep mypy
   working but fixing the python level issues.
1. Printing `pass` after each enum with empty entries.
@lovetox
Copy link
Collaborator

lovetox commented Feb 23, 2025

Hi, thanks for trying to fix this.

Can you add the stubs that you now can generate with the script as a second commit to this PR, so i can see how that change looks if its needed.

@cal0pteryx
Copy link
Contributor

There are several constants/flags beginning with digits, e.g.

  • 80211ApFlags
  • 80211Mode
  • 80211ApSecurityFlags

Since Python classes cannot begin with digits, this is a problem.

The flags mentioned above are described in https://lazka.github.io/pgi-docs/#NM-1.0/classes/AccessPoint.html#properties but are not linked there (probably due to the same circumstances as here).

An eample from Vala docs offers more insights: https://valadoc.org/libnm/NM.@80211ApSecurityFlags.html

So I think instead of quoting these, the generator should skip them but issue a warning. And in the stubs, they should rather be manual overrides named something like NM80211ApFlags ?

@AttilaGombosER
Copy link

@j-baker Added the proposed changes (by @cal0pteryx) and the generated stubs in j-baker#1

@lovetox
Copy link
Collaborator

lovetox commented Mar 26, 2025

I pushed a better solution. Enums/Flags which have a invalid name are returned as "int", this allows the developer to pass the correct type. Of course he has to lookup in the docs what ints are valid, but i dont see a better solution.

So i close this, please generate with these fixes the stubs and create a PR.

Thanks

@lovetox lovetox closed this Mar 26, 2025
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.

4 participants