Return a tuple of methods declared in the class.
(self)
| 244 | __methods = None |
| 245 | |
| 246 | def get_methods(self): |
| 247 | """Return a tuple of methods declared in the class. |
| 248 | """ |
| 249 | import warnings |
| 250 | typename = f'{self.__class__.__module__}.{self.__class__.__name__}' |
| 251 | warnings.warn(f'{typename}.get_methods() is deprecated ' |
| 252 | f'and will be removed in Python 3.16.', |
| 253 | DeprecationWarning, stacklevel=2) |
| 254 | |
| 255 | if self.__methods is None: |
| 256 | d = {} |
| 257 | |
| 258 | def is_local_symbol(ident): |
| 259 | flags = self._table.symbols.get(ident, 0) |
| 260 | return ((flags >> SCOPE_OFF) & SCOPE_MASK) == LOCAL |
| 261 | |
| 262 | for st in self._table.children: |
| 263 | # pick the function-like symbols that are local identifiers |
| 264 | if is_local_symbol(st.name): |
| 265 | match st.type: |
| 266 | case _symtable.TYPE_FUNCTION: |
| 267 | d[st.name] = 1 |
| 268 | case _symtable.TYPE_TYPE_PARAMETERS: |
| 269 | # Get the function-def block in the annotation |
| 270 | # scope 'st' with the same identifier, if any. |
| 271 | scope_name = st.name |
| 272 | for c in st.children: |
| 273 | if c.name == scope_name and c.type == _symtable.TYPE_FUNCTION: |
| 274 | d[scope_name] = 1 |
| 275 | break |
| 276 | self.__methods = tuple(d) |
| 277 | return self.__methods |
| 278 | |
| 279 | |
| 280 | class Symbol: |