Make globals internal-only

pull/11305/head
coletdjnz 2 months ago
parent 4266658602
commit 413ae7693b
No known key found for this signature in database
GPG Key ID: 91984263BB39894A

@ -11,7 +11,7 @@ sys.path.append(str(TEST_DATA_DIR))
importlib.invalidate_caches()
from yt_dlp.plugins import PACKAGE_NAME, PluginType, directories, load_plugins
from yt_dlp.globals import extractors, postprocessors
from yt_dlp._globals import extractors, postprocessors
class TestPlugins(unittest.TestCase):

@ -33,7 +33,7 @@ from .downloader.rtmp import rtmpdump_version
from .extractor import gen_extractor_classes, get_info_extractor, import_extractors
from .extractor.common import UnsupportedURLIE
from .extractor.openload import PhantomJSwrapper
from .globals import (
from ._globals import (
IN_CLI,
LAZY_EXTRACTORS,
plugin_ies,

@ -20,7 +20,7 @@ from .downloader.external import get_external_downloader
from .extractor import list_extractor_classes
from .extractor.adobepass import MSO_INFO
from .networking.impersonate import ImpersonateTarget
from .globals import IN_CLI, plugin_dirs
from ._globals import IN_CLI, plugin_dirs
from .options import parseOpts
from .plugins import load_all_plugin_types
from .postprocessor import (

@ -1,7 +1,7 @@
from collections import defaultdict
from contextvars import ContextVar
# NAME = 'yt-dlp'
# Internal only - no backwards compatibility guaranteed
postprocessors = ContextVar('postprocessors', default={})
extractors = ContextVar('extractors', default={})

@ -1,5 +1,5 @@
from .._globals import extractors as _extractors_context
from ..compat.compat_utils import passthrough_module
from ..globals import extractors as _extractors_context
passthrough_module(__name__, '.extractors')
del passthrough_module

@ -1,8 +1,8 @@
import inspect
import os
from ..globals import LAZY_EXTRACTORS
from ..globals import extractors as _extractors_context
from .._globals import LAZY_EXTRACTORS
from .._globals import extractors as _extractors_context
_CLASS_LOOKUP = None
if not os.environ.get('YTDLP_NO_LAZY_EXTRACTORS'):

@ -17,7 +17,7 @@ from contextvars import ContextVar
from pathlib import Path
from zipfile import ZipFile
from .globals import (
from ._globals import (
extractors,
plugin_dirs,
plugin_ies,
@ -268,7 +268,7 @@ def load_plugins(plugin_type: PluginType):
regular_classes.update(get_regular_modules(plugins, spec.name, suffix))
# Configure override classes
for name, klass in override_classes.items():
for _, klass in override_classes.items():
plugin_name = getattr(klass, '_plugin_name', None)
if not plugin_name:
# these should always have plugin_name
@ -298,6 +298,7 @@ def load_all_plugin_types():
for plugin_type in PluginType:
load_plugins(plugin_type)
sys.meta_path.insert(0, PluginFinder(f'{PACKAGE_NAME}.extractor', f'{PACKAGE_NAME}.postprocessor'))
__all__ = [

@ -33,7 +33,7 @@ from .movefilesafterdownload import MoveFilesAfterDownloadPP
from .sponskrub import SponSkrubPP
from .sponsorblock import SponsorBlockPP
from .xattrpp import XAttrMetadataPP
from ..globals import plugin_pps, postprocessors
from .._globals import plugin_pps, postprocessors
from ..plugins import PACKAGE_NAME
from ..utils import deprecation_warning

@ -52,7 +52,7 @@ from ..compat import (
compat_os_name,
)
from ..dependencies import xattr
from ..globals import IN_CLI
from .._globals import IN_CLI
__name__ = __name__.rsplit('.', 1)[0] # noqa: A001: Pretend to be the parent module

Loading…
Cancel
Save