From 35e06a839d140f1a636e45aab137f689d4239166 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Mon, 13 Jul 2026 09:23:53 +0200 Subject: [PATCH] Remove dead code and stale Python 2 leftovers All verified unreferenced across the package, tests, and docs: - ClassTypes tuple in traitlets.py, a Python 2/3 compat constant never used and not exported - execfile() shim in config/loader.py, shadowing the removed Python 2 builtin, never called - Config._merge in config/loader.py, a deprecated private alias for Config.merge that was never called and never warned --- traitlets/config/application.py | 2 +- traitlets/config/loader.py | 9 --------- traitlets/traitlets.py | 3 --- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/traitlets/config/application.py b/traitlets/config/application.py index 1d475c58..42fe8cb7 100644 --- a/traitlets/config/application.py +++ b/traitlets/config/application.py @@ -67,7 +67,7 @@ """.strip() # trim newlines of front and back # sys.argv can be missing, for example when python is embedded. See the docs -# for details: http://docs.python.org/2/c-api/intro.html#embedding-python +# for details: https://docs.python.org/3/c-api/intro.html#embedding-python if not hasattr(sys, "argv"): sys.argv = [""] diff --git a/traitlets/config/loader.py b/traitlets/config/loader.py index f9eb5fe1..351918b0 100644 --- a/traitlets/config/loader.py +++ b/traitlets/config/loader.py @@ -77,11 +77,6 @@ def print_help(self, file: t.Any = None) -> None: # ----------------------------------------------------------------------------- -def execfile(fname: str, glob: dict[str, Any]) -> None: - with open(fname, "rb") as f: - exec(compile(f.read(), fname, "exec"), glob, glob) # noqa: S102 - - class LazyConfigValue(HasTraits): """Proxy object for exposing methods on configurable containers @@ -250,10 +245,6 @@ def _ensure_subconfig(self) -> None: if _is_section_key(key) and isinstance(obj, dict) and not isinstance(obj, Config): setattr(self, key, Config(obj)) - def _merge(self, other: t.Any) -> None: - """deprecated alias, use Config.merge()""" - self.merge(other) - def merge(self, other: t.Any) -> None: """merge another config object into this one""" to_update = {} diff --git a/traitlets/traitlets.py b/traitlets/traitlets.py index 9c33d2f3..3233f12f 100644 --- a/traitlets/traitlets.py +++ b/traitlets/traitlets.py @@ -62,9 +62,6 @@ SequenceTypes = (list, tuple, set, frozenset) -# backward compatibility, use to differ between Python 2 and 3. -ClassTypes = (type,) - if t.TYPE_CHECKING: from typing_extensions import TypeVar else: