scripts: Adopted del to resolve shadowed builtins

So:

  all_ = all; del all

Instead of:

  import builtins
  all_, all = all, builtins.all

The del exposes the globally scoped builtin we accidentally shadow.

This requires less megic, and no module imports, though tbh I'm
surprised it works.

It also works in the case where you change a builtin globally, but
that's a bit too crazy even for me...
This commit is contained in:
Christopher Haster
2025-03-31 15:40:17 -05:00
parent 8324786121
commit 270230a833
13 changed files with 21 additions and 41 deletions
+1 -2
View File
@@ -604,8 +604,7 @@ def table(Result, results, diff_results=None, *,
small_table=False,
summary=False,
**_):
import builtins
all_, all = all, builtins.all
all_ = all; del all
if by is None:
by = Result._by
+1 -2
View File
@@ -459,8 +459,7 @@ def table(Result, results, diff_results=None, *,
small_table=False,
summary=False,
**_):
import builtins
all_, all = all, builtins.all
all_ = all; del all
if by is None:
by = Result._by
+1 -2
View File
@@ -1748,8 +1748,7 @@ def table(Result, results, diff_results=None, *,
small_table=False,
summary=False,
**_):
import builtins
all_, all = all, builtins.all
all_ = all; del all
if by is None:
by = Result._by
+1 -2
View File
@@ -864,8 +864,7 @@ def table(Result, results, diff_results=None, *,
small_table=False,
summary=False,
**_):
import builtins
all_, all = all, builtins.all
all_ = all; del all
if by is None:
by = Result._by
+1 -2
View File
@@ -604,8 +604,7 @@ def table(Result, results, diff_results=None, *,
small_table=False,
summary=False,
**_):
import builtins
all_, all = all, builtins.all
all_ = all; del all
if by is None:
by = Result._by
+1 -2
View File
@@ -28,8 +28,7 @@ ERRS = [
def main(errs, *,
list=False):
import builtins
list_, list = list, builtins.list
list_ = list; del list
lines = []
# list all known error codes
+2 -3
View File
@@ -194,9 +194,8 @@ FLAGS = [
def main(flags, *,
list=False,
all=False):
import builtins
list_, list = list, builtins.list
all_, all = all, builtins.all
list_ = list; del list
all_ = all; del all
# first compile prefixes
prefixes = {}
+8 -16
View File
@@ -3345,8 +3345,7 @@ class Lfs:
# lookup operations
def lookup(self, mid, mdir=None, *,
all=False):
import builtins
all_, all = all, builtins.all
all_ = all; del all
# is this mid grmed?
if not all_ and self.grmed(mid):
@@ -3367,8 +3366,7 @@ class Lfs:
def namelookup(self, did, name, *,
all=False):
import builtins
all_, all = all, builtins.all
all_ = all; del all
mid_, mdir_, name_ = self.mtree.namelookup(did, name)
if mid_ is None:
@@ -3430,8 +3428,7 @@ class Lfs:
all=False,
path=False,
depth=None):
import builtins
all_, all = all, builtins.all
all_ = all; del all
# default to the root directory
if path_ is None:
@@ -3470,8 +3467,7 @@ class Lfs:
all=False,
path=False,
depth=None):
import builtins
all_, all = all, builtins.all
all_ = all; del all
file, *path__ = self.pathlookup_(did, path_,
all=all_,
@@ -3486,8 +3482,7 @@ class Lfs:
all=False,
path=False,
depth=None):
import builtins
all_, all = all, builtins.all
all_ = all; del all
# default to the root directory
did = did or self.root.did
@@ -3536,8 +3531,7 @@ class Lfs:
all=False,
path=False,
depth=None):
import builtins
all_, all = all, builtins.all
all_ = all; del all
for file, *path__ in self.files_(did,
all=all_,
@@ -3553,8 +3547,7 @@ class Lfs:
def orphans(self,
all=False):
import builtins
all_, all = all, builtins.all
all_ = all; del all
# first find all reachable dids
dids = {self.root.did}
@@ -4069,8 +4062,7 @@ def dbg_files(lfs, paths,
all=False,
no_orphans=False,
**args):
import builtins
all_, all = all, builtins.all
all_ = all; del all
# parse all paths first, error if anything is malformed
dirs = []
+1 -2
View File
@@ -232,8 +232,7 @@ def main(tags, *,
block_count=None,
off=None,
**args):
import builtins
list_, list = list, builtins.list
list_ = list; del list
# list all known tags
if list_:
+1 -2
View File
@@ -965,8 +965,7 @@ def table(Result, results, diff_results=None, *,
small_table=False,
summary=False,
**_):
import builtins
all_, all = all, builtins.all
all_ = all; del all
if by is None:
by = Result._by
+1 -2
View File
@@ -939,8 +939,7 @@ def table(Result, results, diff_results=None, *,
small_table=False,
summary=False,
**_):
import builtins
all_, all = all, builtins.all
all_ = all; del all
if by is None:
by = Result._by
+1 -2
View File
@@ -607,8 +607,7 @@ def table(Result, results, diff_results=None, *,
small_table=False,
summary=False,
**_):
import builtins
all_, all = all, builtins.all
all_ = all; del all
if by is None:
by = Result._by
+1 -2
View File
@@ -745,8 +745,7 @@ def table(Result, results, diff_results=None, *,
small_table=False,
summary=False,
**_):
import builtins
all_, all = all, builtins.all
all_ = all; del all
if by is None:
by = Result._by