Skip to content

Conversation

@jjw24
Copy link
Member

@jjw24 jjw24 commented Dec 15, 2024

Test and validate plugin file name be in the construct of -.json.

Tested:
Previous Nightlight version fails validation

Relates to #430

@jjw24 jjw24 added bug Something isn't working Continuous Integration/Workflow labels Dec 15, 2024
@jjw24 jjw24 requested review from Garulf and Yusyuriv December 15, 2024 07:42
@jjw24 jjw24 self-assigned this Dec 15, 2024
@jjw24 jjw24 enabled auto-merge (squash) December 15, 2024 07:42
Copy link
Member

@Yusyuriv Yusyuriv left a comment

Choose a reason for hiding this comment

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

LGTM. Removing the list comprehension is not very important as its impact on performance is negligible, so I approved the PR in case you don't want to remove the list comprehension.

return [os.path.join(plugin_dir, filename) for filename in get_plugin_filenames()]

def get_plugin_filenames() -> list[str]:
return [file for file in os.listdir(plugin_dir)]
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you don't need a list comprehension in get_plugin_filenames as they return the same data, but list comprehension does slightly more work as it iterates through list one more time:

>>> [v for v in os.listdir('test')]
['script2.py', 'plugin.json', 'file.txt', 'script.py']
>>> os.listdir('test')
['script2.py', 'plugin.json', 'file.txt', 'script.py']
Suggested change
return [file for file in os.listdir(plugin_dir)]
return os.listdir(plugin_dir)

Copy link
Member

Choose a reason for hiding this comment

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

I didn't notice the PR was on auto-merge. Oh well.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes, my mistake, will correct it in the next PR.

@jjw24 jjw24 merged commit 474b7d2 into plugin_api_v2 Dec 15, 2024
8 checks passed
@jjw24 jjw24 deleted the add_filename_construct_validation branch December 15, 2024 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants