Skip to content

Fixup FolderId usage and change log#12986

Merged
seanbudd merged 3 commits into
masterfrom
fixup-12943
Oct 27, 2021
Merged

Fixup FolderId usage and change log#12986
seanbudd merged 3 commits into
masterfrom
fixup-12943

Conversation

@seanbudd

@seanbudd seanbudd commented Oct 25, 2021

Copy link
Copy Markdown
Member

Link to issue number:

Fixup of #12943

Summary of the issue:

Changelog entries were missing for #12943

UpperCamelCase is the standard for class names, including enums, however FOLDERID was used as the casing for the enum, which mirrors the windows constants.
There is a similar issue for the enum members (which used UpperCamelCase instead of CAP_SNAKE_CASE).

If we want to change our practice to be consistent with what an Enum represents, we should update codingStandards.md

Also the enum type was not being fully leveraged by SHGetKnownFolderPath, requiring .value to be used unnecessarily when calling the function.

Description of how this pull request fixes the issue:

Updates the casing of the enum and it's members. Updates the change log, and fixes up some earlier entries.

Testing strategy:

None

Known issues with pull request:

None

Change log entries:

See diff

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English

@seanbudd seanbudd requested a review from a team as a code owner October 25, 2021 23:43
@seanbudd

Copy link
Copy Markdown
Member Author

ccing @feerrenrut as an additional reviewer

what are your thoughts on the discussion of casing of Enum names and members? #12943 (comment)

@seanbudd seanbudd requested a review from feerrenrut October 25, 2021 23:45
@seanbudd

Copy link
Copy Markdown
Member Author

cc @lukaszgo1 @LeonarddeR

@AppVeyorBot

This comment has been minimized.

Comment thread source/shlobj.py Outdated
"""Wrapper for `SHGetKnownFolderPath` which caches the results
to avoid calling the win32 function unnecessarily."""
guid = comtypes.GUID(folderGuid)
guid = comtypes.GUID(folderGuid.value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While this certainly improves readability it also makes this much less usable for consumers of SHGetKnownFolderPath i.e. add-on developers.
Since our FolderId contains only guids of folders which we're actually using in NVDA if someone wants to retrieve path of a different folder (Microsoft lists a lot of them) they would need to implement SHGetKnownFolderPath themselves. Adding all known guids to our enum is also not a solution since list of known folder can be extended by program installers
I'd like to propose modifying this function so that it accepts union[FolderId, str] as its first parameter and then either accesses the value or just creates a comtypes.GUID from the string provided. That way we would offer similar level of flexibility as we used to with our wrapper for SHGetFolderPath in 2021.3.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This sounds reasonable given the requirements.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good point, this should be included now.

@feerrenrut

Copy link
Copy Markdown
Contributor

While camel case (actually "Pascal Case" because of the leading capital) is used for class names (including Enum classes) such as FolderId, the enum values should typically be "SCREAMING_SNAKE_CASE"

@seanbudd

Copy link
Copy Markdown
Member Author

While camel case (actually "Pascal Case" because of the leading capital) is used for class names (including Enum classes) such as FolderId, the enum values should typically be "SCREAMING_SNAKE_CASE"

good catch - fixed

@lukaszgo1 lukaszgo1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@seanbudd seanbudd merged commit d65f4de into master Oct 27, 2021
@seanbudd seanbudd deleted the fixup-12943 branch October 27, 2021 21:56
@nvaccessAuto nvaccessAuto added this to the 2022.1 milestone Oct 27, 2021
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.

7 participants