Skip to content

[Python] Adjust type patterns#4541

Merged
keith-hall merged 5 commits into
sublimehq:masterfrom
deathaxe:pr/python/type-scopes
May 3, 2026
Merged

[Python] Adjust type patterns#4541
keith-hall merged 5 commits into
sublimehq:masterfrom
deathaxe:pr/python/type-scopes

Conversation

@deathaxe
Copy link
Copy Markdown
Collaborator

@deathaxe deathaxe commented May 2, 2026

Addresses #4540

This PR restricts which tokens are scoped support.class.

Scope tokens as type only, if they

  1. follow PascalCase or _PascalCase without underscores in between.
  2. consist of at least 2 chars
    3. do not end with uppercase letter

Single char upper case tokens are now scoped variable.other, which is probably an appropriate scope for "type variables" in generics as well.

It would be possible to keep them scoped support.type in type annotations with further adjustments to related contexts. Those currently use normal expression rules, which causes some ambiguities to resolve - especially with regards to after-expression context.

deathaxe added 4 commits May 2, 2026 08:52
This commit teaches Python to scope identifiers `variable.other`
instead of `support.class` if they contain underscore
to reduce chance of false positives.

Note: Classes still may start with underscore.
This is a formal change, not affecting syntax behavior.
Scope single uppercase letter tokens, variable.other.

May help to reduce false positives and is not semantically
wrong with regards to generics.
keith-hall
keith-hall previously approved these changes May 2, 2026
Comment thread Python/Python.sublime-syntax Outdated
@jrappen jrappen requested a review from keith-hall May 3, 2026 11:30
@keith-hall keith-hall merged commit d7d5b9d into sublimehq:master May 3, 2026
2 checks passed
@deathaxe deathaxe deleted the pr/python/type-scopes branch May 3, 2026 12:02
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.

5 participants