From b00a7c9f9a17ccdfddcd701af60cf02bf4893cb9 Mon Sep 17 00:00:00 2001 From: Julien Palard Date: Fri, 5 Jan 2024 12:41:03 +0100 Subject: [PATCH] Implement missing python special methods. (#467) --- snippets/python-mode/__aenter__ | 8 ++++++++ snippets/python-mode/__aexit__ | 7 +++++++ snippets/python-mode/__aiter__ | 7 +++++++ snippets/python-mode/__anext__ | 7 +++++++ snippets/python-mode/__await__ | 7 +++++++ snippets/python-mode/__bytes__ | 7 +++++++ snippets/python-mode/__ceil__ | 7 +++++++ snippets/python-mode/__class_getitem__ | 7 +++++++ snippets/python-mode/__dir__ | 7 +++++++ snippets/python-mode/__floor__ | 7 +++++++ snippets/python-mode/__format__ | 7 +++++++ snippets/python-mode/__imatmul__ | 7 +++++++ snippets/python-mode/__init_subclass__ | 8 ++++++++ snippets/python-mode/__length_hint__ | 7 +++++++ snippets/python-mode/__matmul__ | 7 +++++++ snippets/python-mode/__missing__ | 7 +++++++ snippets/python-mode/__prepare__ | 7 +++++++ snippets/python-mode/__rmatmul__ | 7 +++++++ snippets/python-mode/__round__ | 7 +++++++ snippets/python-mode/__set_name__ | 7 +++++++ snippets/python-mode/__trunc__ | 7 +++++++ 21 files changed, 149 insertions(+) create mode 100644 snippets/python-mode/__aenter__ create mode 100644 snippets/python-mode/__aexit__ create mode 100644 snippets/python-mode/__aiter__ create mode 100644 snippets/python-mode/__anext__ create mode 100644 snippets/python-mode/__await__ create mode 100644 snippets/python-mode/__bytes__ create mode 100644 snippets/python-mode/__ceil__ create mode 100644 snippets/python-mode/__class_getitem__ create mode 100644 snippets/python-mode/__dir__ create mode 100644 snippets/python-mode/__floor__ create mode 100644 snippets/python-mode/__format__ create mode 100644 snippets/python-mode/__imatmul__ create mode 100644 snippets/python-mode/__init_subclass__ create mode 100644 snippets/python-mode/__length_hint__ create mode 100644 snippets/python-mode/__matmul__ create mode 100644 snippets/python-mode/__missing__ create mode 100644 snippets/python-mode/__prepare__ create mode 100644 snippets/python-mode/__rmatmul__ create mode 100644 snippets/python-mode/__round__ create mode 100644 snippets/python-mode/__set_name__ create mode 100644 snippets/python-mode/__trunc__ diff --git a/snippets/python-mode/__aenter__ b/snippets/python-mode/__aenter__ new file mode 100644 index 00000000..1e6db3bb --- /dev/null +++ b/snippets/python-mode/__aenter__ @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: __aenter__ +# key: _aenter +# group: Special methods +# -- +async def __aenter__(self): + $0 + return self diff --git a/snippets/python-mode/__aexit__ b/snippets/python-mode/__aexit__ new file mode 100644 index 00000000..78ab8e2b --- /dev/null +++ b/snippets/python-mode/__aexit__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __aexit__ +# key: _aexit +# group: Special methods +# -- +async def __aexit__(self, exc_type, exc_value, traceback): + $0 diff --git a/snippets/python-mode/__aiter__ b/snippets/python-mode/__aiter__ new file mode 100644 index 00000000..3c8e08ba --- /dev/null +++ b/snippets/python-mode/__aiter__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __aiter__ +# key: _aiter +# group: Special methods +# -- +def __aiter__(self): + return $0 diff --git a/snippets/python-mode/__anext__ b/snippets/python-mode/__anext__ new file mode 100644 index 00000000..aaab2fac --- /dev/null +++ b/snippets/python-mode/__anext__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __anext__ +# key: _anext +# group: Special methods +# -- +async def __anext__(self): + return $0 diff --git a/snippets/python-mode/__await__ b/snippets/python-mode/__await__ new file mode 100644 index 00000000..10463d55 --- /dev/null +++ b/snippets/python-mode/__await__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __await__ +# key: _await +# group: Special methods +# -- +def __await__(self): + $0 diff --git a/snippets/python-mode/__bytes__ b/snippets/python-mode/__bytes__ new file mode 100644 index 00000000..f1ab4c96 --- /dev/null +++ b/snippets/python-mode/__bytes__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __bytes__ +# key: _bytes +# group: Special methods +# -- +def __bytes__(self): + return $0 diff --git a/snippets/python-mode/__ceil__ b/snippets/python-mode/__ceil__ new file mode 100644 index 00000000..8ea4c81f --- /dev/null +++ b/snippets/python-mode/__ceil__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __ceil__ +# key: _ceil +# group: Special methods +# -- +def __ceil__(self): + return $0 diff --git a/snippets/python-mode/__class_getitem__ b/snippets/python-mode/__class_getitem__ new file mode 100644 index 00000000..9a3f99f8 --- /dev/null +++ b/snippets/python-mode/__class_getitem__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __class_getitem__ +# key: _class_getitem +# group: Special methods +# -- +def __class_getitem__(cls, key): + return $0 diff --git a/snippets/python-mode/__dir__ b/snippets/python-mode/__dir__ new file mode 100644 index 00000000..0eef3643 --- /dev/null +++ b/snippets/python-mode/__dir__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __dir__ +# key: _dir +# group: Special methods +# -- +def __dir__(self): + return $0 diff --git a/snippets/python-mode/__floor__ b/snippets/python-mode/__floor__ new file mode 100644 index 00000000..9c594122 --- /dev/null +++ b/snippets/python-mode/__floor__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __floor__ +# key: _floor +# group: Special methods +# -- +def __floor__(self): + return $0 diff --git a/snippets/python-mode/__format__ b/snippets/python-mode/__format__ new file mode 100644 index 00000000..efbe00c0 --- /dev/null +++ b/snippets/python-mode/__format__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __format__ +# key: _format +# group: Special methods +# -- +def __format__(self, format_spec): + return $0 diff --git a/snippets/python-mode/__imatmul__ b/snippets/python-mode/__imatmul__ new file mode 100644 index 00000000..e162beed --- /dev/null +++ b/snippets/python-mode/__imatmul__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __imatmul__ +# key: _imatmul +# group: Special methods +# -- +def __imatmul__(self, other): + return $0 diff --git a/snippets/python-mode/__init_subclass__ b/snippets/python-mode/__init_subclass__ new file mode 100644 index 00000000..371f264c --- /dev/null +++ b/snippets/python-mode/__init_subclass__ @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: __init_subclass__ +# key: _init_subclass +# group: Special methods +# -- +def __init_subclass__(cls, /${1:, param}, **kwargs): + super().__init_subclass__(**kwargs) + $0 diff --git a/snippets/python-mode/__length_hint__ b/snippets/python-mode/__length_hint__ new file mode 100644 index 00000000..4725963a --- /dev/null +++ b/snippets/python-mode/__length_hint__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __length_hint__ +# key: _length_hint +# group: Special methods +# -- +def __length_hint__(self): + return $0 diff --git a/snippets/python-mode/__matmul__ b/snippets/python-mode/__matmul__ new file mode 100644 index 00000000..983d29bc --- /dev/null +++ b/snippets/python-mode/__matmul__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __matmul__ +# key: _matmul +# group: Special methods +# -- +def __matmul__(self, other): + return $0 diff --git a/snippets/python-mode/__missing__ b/snippets/python-mode/__missing__ new file mode 100644 index 00000000..bf798515 --- /dev/null +++ b/snippets/python-mode/__missing__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __missing__ +# key: _missing +# group: Special methods +# -- +def __missing__(self): + return $0 diff --git a/snippets/python-mode/__prepare__ b/snippets/python-mode/__prepare__ new file mode 100644 index 00000000..0041ab06 --- /dev/null +++ b/snippets/python-mode/__prepare__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __prepare__ +# key: _prepare +# group: Special methods +# -- +def __prepare__(name, bases, **kwds): + return ${0:\{\}} diff --git a/snippets/python-mode/__rmatmul__ b/snippets/python-mode/__rmatmul__ new file mode 100644 index 00000000..2acfe418 --- /dev/null +++ b/snippets/python-mode/__rmatmul__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __rmatmul__ +# key: _rmatmul +# group: Special methods +# -- +def __rmatmul__(self, other): + return $0 diff --git a/snippets/python-mode/__round__ b/snippets/python-mode/__round__ new file mode 100644 index 00000000..5d6c3f1d --- /dev/null +++ b/snippets/python-mode/__round__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __round__ +# key: _round +# group: Special methods +# -- +def __round__(self, ndigits=None): + return $0 diff --git a/snippets/python-mode/__set_name__ b/snippets/python-mode/__set_name__ new file mode 100644 index 00000000..5bba1fec --- /dev/null +++ b/snippets/python-mode/__set_name__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __set_name__ +# key: _set_name +# group: Special methods +# -- +def __set_name__(self, owner, name): + $0 diff --git a/snippets/python-mode/__trunc__ b/snippets/python-mode/__trunc__ new file mode 100644 index 00000000..52401bf1 --- /dev/null +++ b/snippets/python-mode/__trunc__ @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: __trunc__ +# key: _trunc +# group: Special methods +# -- +def __trunc__(self): + return $0