Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23310f4

Browse files
committed
Clean up debug print statements
1 parent78f9b8a commit23310f4

File tree

2 files changed

+23
-94
lines changed

2 files changed

+23
-94
lines changed

‎salt/loader/lazy.py‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -626,20 +626,8 @@ def __prep_mod_opts(self, opts):
626626
"""
627627
if"__grains__"notinself.pack:
628628
grains=opts.get("grains", {})
629-
importsys
630-
631-
print(
632-
f"[LAZYLOADER] Got grains from opts: type={type(grains).__name__}, len={len(grains)ifisinstance(grains,dict)else'N/A'}, is_context={isinstance(grains,salt.loader.context.NamedLoaderContext)}",
633-
file=sys.stderr,
634-
flush=True,
635-
)
636629
ifisinstance(grains,salt.loader.context.NamedLoaderContext):
637630
grains=grains.value()
638-
print(
639-
f"[LAZYLOADER] After .value(): type={type(grains).__name__}, len={len(grains)ifisinstance(grains,dict)else'N/A'}",
640-
file=sys.stderr,
641-
flush=True,
642-
)
643631
self.pack["__grains__"]=grains
644632

645633
if"__pillar__"notinself.pack:

‎salt/utils/optsdict.py‎

Lines changed: 23 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ def __init__(self, target: dict, parent_optsdict: "OptsDict", key: str):
5353
object.__setattr__(self,"_parent",parent_optsdict)
5454
object.__setattr__(self,"_key",key)
5555
object.__setattr__(self,"_copied",False)
56-
importsys
57-
58-
print(
59-
f"[DICTPROXY] Created DictProxy for key={key}, target type={type(target).__name__}, target len={len(target)}, target id={id(target)}",
60-
file=sys.stderr,
61-
flush=True,
62-
)
6356

6457
def_ensure_copied(self):
6558
"""Copy target to parent's _local on first mutation."""
@@ -109,16 +102,7 @@ def __iter__(self):
109102
returniter(object.__getattribute__(self,"_target"))
110103

111104
def__len__(self):
112-
target=object.__getattribute__(self,"_target")
113-
key=object.__getattribute__(self,"_key")
114-
importsys
115-
116-
print(
117-
f"[DICTPROXY] __len__ called for key={key}, target id={id(target)}, target len={len(target)}",
118-
file=sys.stderr,
119-
flush=True,
120-
)
121-
returnlen(target)
105+
returnlen(object.__getattribute__(self,"_target"))
122106

123107
def__repr__(self):
124108
returnrepr(object.__getattribute__(self,"_target"))
@@ -527,42 +511,22 @@ def __getitem__(self, key: str) -> Any:
527511
iffound:
528512
# Wrap mutable values in proxies to catch mutations
529513
ifisinstance(value,dict)andnotisinstance(value,OptsDict):
530-
importsys
531-
532-
print(
533-
f"[OPTSDICT] __getitem__({key}): Creating DictProxy from parent chain, value type={type(value).__name__}, len={len(value)ifisinstance(value,dict)else'N/A'}, id={id(value)}",
534-
file=sys.stderr,
535-
flush=True,
536-
)
537514
returnDictProxy(value,self,key)
538515
elifisinstance(value,list):
539516
returnListProxy(value,self,key)
540517
# Immutable values can be returned directly
541518
returnvalue
542519

543520
# Check base (root level only)
544-
ifself._parentisNone:
545-
importsys
546-
547-
print(
548-
f"[OPTSDICT] __getitem__({key}): Checking base, key in base={keyinself._base}, base id={id(self._base)}, base keys={list(self._base.keys())[:10]}",
549-
file=sys.stderr,
550-
flush=True,
551-
)
552-
ifkeyinself._base:
553-
value=self._base[key]
554-
# Even root instances need proxies to track when values are mutated
555-
# This allows us to know when a key has been accessed/modified
556-
ifisinstance(value,dict)andnotisinstance(value,OptsDict):
557-
print(
558-
f"[OPTSDICT] __getitem__({key}): Creating DictProxy from base, value type={type(value).__name__}, len={len(value)ifisinstance(value,dict)else'N/A'}, id={id(value)}",
559-
file=sys.stderr,
560-
flush=True,
561-
)
562-
returnDictProxy(value,self,key)
563-
elifisinstance(value,list):
564-
returnListProxy(value,self,key)
565-
returnvalue
521+
ifself._parentisNoneandkeyinself._base:
522+
value=self._base[key]
523+
# Even root instances need proxies to track when values are mutated
524+
# This allows us to know when a key has been accessed/modified
525+
ifisinstance(value,dict)andnotisinstance(value,OptsDict):
526+
returnDictProxy(value,self,key)
527+
elifisinstance(value,list):
528+
returnListProxy(value,self,key)
529+
returnvalue
566530

567531
raiseKeyError(key)
568532

@@ -891,50 +855,27 @@ def safe_opts_copy(opts: Any, name: str | None = None) -> OptsDict:
891855
from salt.utils.optsdict import safe_opts_copy
892856
opts = safe_opts_copy(opts, name="loader:states")
893857
"""
894-
global_dict_to_root
895-
896858
ifisinstance(opts,OptsDict):
897859
# Find the root of this OptsDict tree
898860
root=opts
899861
whileroot._parentisnotNone:
900862
root=root._parent
901863

902-
importsys
903-
904-
print(
905-
f"[OPTSDICT] safe_opts_copy called with OptsDict (name={opts._name}), found root={root._name}, creating child of root with name={name}",
906-
file=sys.stderr,
907-
flush=True,
908-
)
909-
910864
# Always create children from the root to ensure all children are siblings
911865
# This allows them to see each other's mutations through the root's _local
912866
returnOptsDict.from_parent(root,name=name)
913-
else:
914-
# Converting from regular dict
915-
# Check if we've already created a root for this specific dict object
916-
opts_id=id(opts)
917-
ifopts_idin_dict_to_root:
918-
# Reuse existing root - this ensures all OptsDict instances
919-
# from the same source dict share the same base and see mutations
920-
root=_dict_to_root[opts_id]
921-
importsys
922867

923-
print(
924-
f"[OPTSDICT] Reusing root for dict id={opts_id}, has grains={'grains'inopts}, name={name}",
925-
file=sys.stderr,
926-
flush=True,
927-
)
928-
returnOptsDict.from_parent(root,name=name)
929-
else:
930-
# First time seeing this dict - create a new root that wraps it
931-
root=OptsDict.from_dict(opts,name=nameorf"root@{opts_id}")
932-
_dict_to_root[opts_id]=root
933-
importsys
868+
# Converting from regular dict
869+
# Check if we've already created a root for this specific dict object
870+
global_dict_to_root# pylint: disable=global-variable-not-assigned
871+
opts_id=id(opts)
872+
ifopts_idin_dict_to_root:
873+
# Reuse existing root - this ensures all OptsDict instances
874+
# from the same source dict share the same base and see mutations
875+
root=_dict_to_root[opts_id]
876+
returnOptsDict.from_parent(root,name=name)
934877

935-
print(
936-
f"[OPTSDICT] Created NEW root for dict id={opts_id}, has grains={'grains'inopts}, name={name}",
937-
file=sys.stderr,
938-
flush=True,
939-
)
940-
returnroot
878+
# First time seeing this dict - create a new root that wraps it
879+
root=OptsDict.from_dict(opts,name=nameorf"root@{opts_id}")
880+
_dict_to_root[opts_id]=root
881+
returnroot

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp