|
31 | 31 | import warnings
|
32 | 32 |
|
33 | 33 | from abc import ABC, ABCMeta
|
34 |
| -from typing import Dict, List, Optional, Sequence, Tuple, Union, ValuesView |
| 34 | +from typing import Any, Dict, List, Optional, Sequence, Tuple, Union, ValuesView |
35 | 35 |
|
36 | 36 | from .charsets import MYSQL_CHARACTER_SETS, MYSQL_CHARACTER_SETS_57
|
37 | 37 | from .errors import ProgrammingError
|
@@ -112,8 +112,18 @@ def flag_is_set(flag: int, flags: int) -> bool:
|
112 | 112 |
|
113 | 113 |
|
114 | 114 | def _obsolete_option(name: str, new_name: str, value: int) -> int:
|
| 115 | + """Raise a deprecation warning and advise a new option name. |
| 116 | +
|
| 117 | + Args: |
| 118 | + name (str): The name of the option. |
| 119 | + new_name (str): The new option name. |
| 120 | + value (int): The value of the option. |
| 121 | +
|
| 122 | + Returns: |
| 123 | + int: The value of the option. |
| 124 | + """ |
115 | 125 | warnings.warn(
|
116 |
| - f'The option "{name}" has been deprecated, use "{new_name}" instead.', |
| 126
+ f"The option '{name}' has been deprecated, use '{new_name}' instead.", |
117 | 127 | category=DeprecationWarning,
|
118 | 128 | )
|
119 | 129 | return value
|
@@ -339,7 +349,27 @@ class FieldFlag(_Flags):
|
339 | 349 | }
|
340 | 350 |
|
341 | 351 |
|
342 |
| -class ServerCmd(_Constants): |
| 352 | +class ServerCmdMeta(ABCMeta): |
| 353 | + """ClientFlag Metaclass.""" |
| 354 | + |
| 355 | + def __getattribute__(cls, name: str) -> Any: |
| 356 | + deprecated_options = ( |
| 357 | + "FIELD_LIST", |
| 358 | + "REFRESH", |
| 359 | + "SHUTDOWN", |
| 360 | + "PROCESS_INFO", |
| 361 | + "PROCESS_KILL", |
| 362 | + ) |
| 363 | + if name in deprecated_options: |
| 364 | + warnings.warn( |
| 365 | + f"The option 'ServerCmd.{name}' is deprecated and will be removed in " |
| 366 | + "a future release.", |
| 367 | + category=DeprecationWarning, |
| 368 | + ) |
| 369 | + return super().__getattribute__(name) |
| 370 | + |
| 371 | + |
| 372 | +class ServerCmd(_Constants, metaclass=ServerCmdMeta): |
343 | 373 | """MySQL Server Commands"""
|
344 | 374 |
|
345 | 375 | _prefix: str = "COM_"
|
|
0 commit comments