1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-04 19:40:02 +03:00

[2255] Update Dep Comment Format

This commit is contained in:
David Sangrey 2024-06-09 15:52:44 -04:00
parent 13e74f2c57
commit 7d5fdb2b84
No known key found for this signature in database
GPG Key ID: 3AEADBB0186884BC
4 changed files with 16 additions and 8 deletions

View File

@ -328,6 +328,7 @@ class AbstractConfig(abc.ABC):
:raises OSError: On Windows, if a Registry error occurs.
:return: The data or the default.
"""
# DEPRECATED: Migrate to specific type getters. Will remove in 6.0 or later.
warnings.warn('get is Deprecated. use the specific getter for your type', DeprecationWarning, stacklevel=2)
if (a_list := self._suppress_call(self.get_list, ValueError, key, default=None)) is not None:
@ -386,6 +387,7 @@ class AbstractConfig(abc.ABC):
See get_int for its replacement.
:raises OSError: On Windows, if a Registry error occurs.
"""
# DEPRECATED: Migrate to get_int. Will remove in 6.0 or later.
warnings.warn('getint is Deprecated. Use get_int instead', DeprecationWarning, stacklevel=2)
return self.get_int(key, default=default)
@ -443,6 +445,7 @@ class AbstractConfig(abc.ABC):
"""Close this config and release any associated resources."""
raise NotImplementedError
# DEPRECATED: Password system doesn't do anything. Will remove in 6.0 or later.
def get_password(self, account: str) -> None:
"""Legacy password retrieval."""
warnings.warn("password subsystem is no longer supported", DeprecationWarning, stacklevel=2)
@ -454,6 +457,7 @@ class AbstractConfig(abc.ABC):
def delete_password(self, account: str) -> None:
"""Legacy password deletion."""
warnings.warn("password subsystem is no longer supported", DeprecationWarning, stacklevel=2)
# End Dep Zone
def get_config(*args, **kwargs) -> AbstractConfig:
@ -486,6 +490,7 @@ def get_update_feed() -> str:
return 'https://raw.githubusercontent.com/EDCD/EDMarketConnector/releases/edmarketconnector.xml'
# DEPRECATED: Migrate to get_update_feed(). Will remove in 6.0 or later.
def __getattr__(name: str):
if name == 'update_feed':
warnings.warn('update_feed is deprecated, and will be removed in 6.0 or later. '

15
l10n.py
View File

@ -86,8 +86,7 @@ class Translations:
Use when translation is not desired or not available
"""
self.translations = {None: {}}
# WARNING: '_' is Deprecated. Will be removed in 6.0 or later.
# Migrate to calling translations.translate or tr.tl directly.
# DEPRECATED: Migrate to translations.translate or tr.tl. Will remove in 6.0 or later.
builtins.__dict__['_'] = lambda x: str(x).replace(r'\"', '"').replace('{CR}', '\n')
def install(self, lang: str | None = None) -> None: # noqa: CCR001
@ -131,8 +130,7 @@ class Translations:
except Exception:
logger.exception(f'Exception occurred while parsing {lang}.strings in plugin {plugin}')
# WARNING: '_' is Deprecated. Will be removed in 6.0 or later.
# Migrate to calling translations.translate or tr.tl directly.
# DEPRECATED: Migrate to translations.translate or tr.tl. Will remove in 6.0 or later.
builtins.__dict__['_'] = self.translate
def contents(self, lang: str, plugin_path: str | None = None) -> dict[str, str]:
@ -262,14 +260,17 @@ class Translations:
class _Locale:
"""Locale holds a few utility methods to convert data to and from localized versions."""
def stringFromNumber(self, number: float | int, decimals: int | None = None) -> str: # noqa: N802
# DEPRECATED: Migrate to _Locale.string_from_number. Will remove in 6.0 or later.
def stringFromNumber(self, number: float | int, decimals: int | None = None) -> str: # noqa:
warnings.warn('use _Locale.string_from_number instead.', DeprecationWarning, stacklevel=2)
return self.string_from_number(number, decimals) # type: ignore
# DEPRECATED: Migrate to _Locale.number_from_string. Will remove in 6.0 or later.
def numberFromString(self, string: str) -> int | float | None: # noqa: N802
warnings.warn('use _Locale.number_from_string instead.', DeprecationWarning, stacklevel=2)
return self.number_from_string(string)
# DEPRECATED: Migrate to _Locale.preferred_languages. Will remove in 6.0 or later.
def preferredLanguages(self) -> Iterable[str]: # noqa: N802
warnings.warn('use _Locale.preferred_languages instead.', DeprecationWarning, stacklevel=2)
return self.preferred_languages()
@ -362,8 +363,8 @@ Locale = _Locale()
translations = Translations()
# WARNING: 'Translations' singleton is deprecated. Will be removed in 6.0 or later.
# Migrate to importing 'translations'.
# DEPRECATED: Migrate to `translations`. Will be removed in 6.0 or later.
# 'Translations' singleton is deprecated.
# Begin Deprecation Zone
class _Translations(Translations):
def __init__(self):

View File

@ -125,6 +125,7 @@ class EntryMenu(ttk.Entry):
class Entry(EntryMenu):
"""Custom ttk.Entry class to fix some display issues."""
# DEPRECATED: Migrate to EntryMenu. Will remove in 6.0 or later.
def __init__(self, master: ttk.Frame | None = None, **kw):
warnings.warn('Migrate to EntryMenu. Will remove in 6.0 or later.', DeprecationWarning, stacklevel=2)
EntryMenu.__init__(self, master, **kw)
@ -143,6 +144,7 @@ class Button(ttk.Button):
class ColoredButton(tk.Button):
"""Custom tk.Button class to fix some display issues."""
# DEPRECATED: Migrate to tk.Button. Will remove in 6.0 or later.
def __init__(self, master: ttk.Frame | None = None, **kw):
warnings.warn('Migrate to tk.Button. Will remove in 6.0 or later.', DeprecationWarning, stacklevel=2)
tk.Button.__init__(self, master, **kw)

View File

@ -38,7 +38,7 @@ logger = get_main_logger()
# May be imported by plugins
# DEPRECATED: Migrate to open_log_folder. Will remove in 6.0 or later.
def help_open_log_folder() -> None:
"""Open the folder logs are stored in."""
warnings.warn('prefs.help_open_log_folder is deprecated, use open_log_folder instead. '