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, small_table=False,
summary=False, summary=False,
**_): **_):
import builtins all_ = all; del all
all_, all = all, builtins.all
if by is None: if by is None:
by = Result._by by = Result._by
+1 -2
View File
@@ -459,8 +459,7 @@ def table(Result, results, diff_results=None, *,
small_table=False, small_table=False,
summary=False, summary=False,
**_): **_):
import builtins all_ = all; del all
all_, all = all, builtins.all
if by is None: if by is None:
by = Result._by by = Result._by
+1 -2
View File
@@ -1748,8 +1748,7 @@ def table(Result, results, diff_results=None, *,
small_table=False, small_table=False,
summary=False, summary=False,
**_): **_):
import builtins all_ = all; del all
all_, all = all, builtins.all
if by is None: if by is None:
by = Result._by by = Result._by
+1 -2
View File
@@ -864,8 +864,7 @@ def table(Result, results, diff_results=None, *,
small_table=False, small_table=False,
summary=False, summary=False,
**_): **_):
import builtins all_ = all; del all
all_, all = all, builtins.all
if by is None: if by is None:
by = Result._by by = Result._by
+1 -2
View File
@@ -604,8 +604,7 @@ def table(Result, results, diff_results=None, *,
small_table=False, small_table=False,
summary=False, summary=False,
**_): **_):
import builtins all_ = all; del all
all_, all = all, builtins.all
if by is None: if by is None:
by = Result._by by = Result._by
+1 -2
View File
@@ -28,8 +28,7 @@ ERRS = [
def main(errs, *, def main(errs, *,
list=False): list=False):
import builtins list_ = list; del list
list_, list = list, builtins.list
lines = [] lines = []
# list all known error codes # list all known error codes
+2 -3
View File
@@ -194,9 +194,8 @@ FLAGS = [
def main(flags, *, def main(flags, *,
list=False, list=False,
all=False): all=False):
import builtins list_ = list; del list
list_, list = list, builtins.list all_ = all; del all
all_, all = all, builtins.all
# first compile prefixes # first compile prefixes
prefixes = {} prefixes = {}
+8 -16
View File
@@ -3345,8 +3345,7 @@ class Lfs:
# lookup operations # lookup operations
def lookup(self, mid, mdir=None, *, def lookup(self, mid, mdir=None, *,
all=False): all=False):
import builtins all_ = all; del all
all_, all = all, builtins.all
# is this mid grmed? # is this mid grmed?
if not all_ and self.grmed(mid): if not all_ and self.grmed(mid):
@@ -3367,8 +3366,7 @@ class Lfs:
def namelookup(self, did, name, *, def namelookup(self, did, name, *,
all=False): all=False):
import builtins all_ = all; del all
all_, all = all, builtins.all
mid_, mdir_, name_ = self.mtree.namelookup(did, name) mid_, mdir_, name_ = self.mtree.namelookup(did, name)
if mid_ is None: if mid_ is None:
@@ -3430,8 +3428,7 @@ class Lfs:
all=False, all=False,
path=False, path=False,
depth=None): depth=None):
import builtins all_ = all; del all
all_, all = all, builtins.all
# default to the root directory # default to the root directory
if path_ is None: if path_ is None:
@@ -3470,8 +3467,7 @@ class Lfs:
all=False, all=False,
path=False, path=False,
depth=None): depth=None):
import builtins all_ = all; del all
all_, all = all, builtins.all
file, *path__ = self.pathlookup_(did, path_, file, *path__ = self.pathlookup_(did, path_,
all=all_, all=all_,
@@ -3486,8 +3482,7 @@ class Lfs:
all=False, all=False,
path=False, path=False,
depth=None): depth=None):
import builtins all_ = all; del all
all_, all = all, builtins.all
# default to the root directory # default to the root directory
did = did or self.root.did did = did or self.root.did
@@ -3536,8 +3531,7 @@ class Lfs:
all=False, all=False,
path=False, path=False,
depth=None): depth=None):
import builtins all_ = all; del all
all_, all = all, builtins.all
for file, *path__ in self.files_(did, for file, *path__ in self.files_(did,
all=all_, all=all_,
@@ -3553,8 +3547,7 @@ class Lfs:
def orphans(self, def orphans(self,
all=False): all=False):
import builtins all_ = all; del all
all_, all = all, builtins.all
# first find all reachable dids # first find all reachable dids
dids = {self.root.did} dids = {self.root.did}
@@ -4069,8 +4062,7 @@ def dbg_files(lfs, paths,
all=False, all=False,
no_orphans=False, no_orphans=False,
**args): **args):
import builtins all_ = all; del all
all_, all = all, builtins.all
# parse all paths first, error if anything is malformed # parse all paths first, error if anything is malformed
dirs = [] dirs = []
+1 -2
View File
@@ -232,8 +232,7 @@ def main(tags, *,
block_count=None, block_count=None,
off=None, off=None,
**args): **args):
import builtins list_ = list; del list
list_, list = list, builtins.list
# list all known tags # list all known tags
if list_: if list_:
+1 -2
View File
@@ -965,8 +965,7 @@ def table(Result, results, diff_results=None, *,
small_table=False, small_table=False,
summary=False, summary=False,
**_): **_):
import builtins all_ = all; del all
all_, all = all, builtins.all
if by is None: if by is None:
by = Result._by by = Result._by
+1 -2
View File
@@ -939,8 +939,7 @@ def table(Result, results, diff_results=None, *,
small_table=False, small_table=False,
summary=False, summary=False,
**_): **_):
import builtins all_ = all; del all
all_, all = all, builtins.all
if by is None: if by is None:
by = Result._by by = Result._by
+1 -2
View File
@@ -607,8 +607,7 @@ def table(Result, results, diff_results=None, *,
small_table=False, small_table=False,
summary=False, summary=False,
**_): **_):
import builtins all_ = all; del all
all_, all = all, builtins.all
if by is None: if by is None:
by = Result._by by = Result._by
+1 -2
View File
@@ -745,8 +745,7 @@ def table(Result, results, diff_results=None, *,
small_table=False, small_table=False,
summary=False, summary=False,
**_): **_):
import builtins all_ = all; del all
all_, all = all, builtins.all
if by is None: if by is None:
by = Result._by by = Result._by