Skip to content

Commit 1ca3f05

Browse files
authored
[Python] Add various magic functions and variables (#4327)
* [Python] Add module-level magic variable * [Python] Add class-level magic funcs and vars
1 parent 91efa9b commit 1ca3f05

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

Python/Python.sublime-syntax

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ variables:
245245
| aenter | aexit
246246
# other class magic
247247
| call | del | init | new | init_subclass
248-
| instancecheck | subclasscheck
248+
| instancecheck | sizeof | subclasscheck | subclasshook
249249
# pickling
250250
| getnewargs | getnewargs_ex | getstate | setstate | reduce | reduce_ex
251251
# descriptors
@@ -263,11 +263,11 @@ variables:
263263
# generic object
264264
class | dict | doc | module | name
265265
# module-specific / global
266-
| all | file | package
266+
| all | builtins | cached | file | loader | package | path | spec
267267
# functions & methods
268268
| annotations | closure | code | defaults | func | globals | kwdefaults | self | qualname
269269
# classes (attributes)
270-
| bases | prepare | slots | metaclass | mro
270+
| bases | prepare | slots | metaclass | mro | weakref
271271
# Python 2
272272
| members | methods
273273
# Python 3.12 (PEP 698)

Python/tests/syntax_test_python.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,22 @@
451451
#^^^^ - invalid.illegal.name
452452

453453
__all__
454-
#^^^^^^ meta.path support.variable.magic - meta.generic-name
454+
#^^^^^^ meta.path.python support.variable.magic.python
455+
__builtins__
456+
#^^^^^^^^^^^ meta.path.python support.variable.magic.python
457+
__cached__
458+
#^^^^^^^^^ meta.path.python support.variable.magic.python
455459
__file__
456-
#^^^^^^^ support.variable.magic
460+
#^^^^^^^ meta.path.python support.variable.magic.python
461+
__loader__
462+
#^^^^^^^^^ meta.path.python support.variable.magic.python
463+
__package__
464+
#^^^^^^^^^^ meta.path.python support.variable.magic.python
465+
__path__
466+
#^^^^^^^ meta.path.python support.variable.magic.python
467+
__spec__
468+
#^^^^^^^ meta.path.python support.variable.magic.python
469+
457470
__missing__
458471
#^^^^^^^^^^ support.function.magic
459472
__bool__ abc.__nonzero__

0 commit comments

Comments
 (0)