Skip to content

Conversation

@deathaxe
Copy link
Member

ST4 has been shipping sublime.RegionFlags for quite a while.

Maybe worth to switch from 3rd-party to built-in solution.

Note: requires ST4135+.

ST4 has been shipping `sublime.RegionFlags` for quite a while.
Time to switch from 3rd-party to built-in solution.
Copy link
Member

@FichteFoll FichteFoll left a comment

Choose a reason for hiding this comment

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

Thanks. I'll leave this unmerged until the next release to remind myself to adjust the release channel for the ST build requirement.

Example:
flags: sublime.RegionFlags = region_flags_from_strings(["DRAW_EMPTY", "DRAW_NO_FILL"])
"""
return RegionFlags(sum(getattr(RegionFlags, n, RegionFlags.NONE) for n in flag_names))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return RegionFlags(sum(getattr(RegionFlags, n, RegionFlags.NONE) for n in flag_names))
return sum(getattr(RegionFlags, n, RegionFlags.NONE) for n in set(flag_names))

Isn't the outer RegionFlags call redundant since we're already getting and summing RegionFlags "instances"? Also wrapping in a set to deduplicate the strings and prevent unintended side effects.

Copy link
Member Author

Choose a reason for hiding this comment

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

Runtime yes, typechecker/linter no. Without that pyright/basedpyright complains about any assignments.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants