[calm - Cygwin server-side packaging maintenance script] branch master, updated. 20200611-4-g04bd5e1

Jon TURNEY via Cygwin-apps-cvs <[email protected]>
Newsgroups gmane.os.cygwin.cvs.apps
Message-ID <[email protected]>


https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=04bd5e1f23173972fcb095c6d34167fe55765313

commit 04bd5e1f23173972fcb095c6d34167fe55765313
Author: Jon Turney <[email protected]>
Date:   Thu Jun 11 16:01:27 2020 +0100

    Also use flake8-builtins in CI

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=971a99a1ea11874f0cb4e30dc2c24c1d664aaf5a

commit 971a99a1ea11874f0cb4e30dc2c24c1d664aaf5a
Author: Jon Turney <[email protected]>
Date:   Thu Jun 11 16:06:46 2020 +0100

    Avoid shadowing 'dir' builtin
    
    A001 "dir" is a python builtin and is being shadowed, consider renaming the variable

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=00aa2d297c2c10942fb7b7aded4927a733350b8b

commit 00aa2d297c2c10942fb7b7aded4927a733350b8b
Author: Jon Turney <[email protected]>
Date:   Mon May 18 18:11:56 2020 +0100

    Avoid shadowing 'object' builtin
    
    A002 "object" is used as an argument and thus shadows a python builtin, consider renaming the argument

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=945c5344a60bcdc03483a4c58391dfe385085176

commit 945c5344a60bcdc03483a4c58391dfe385085176
Author: Jon Turney <[email protected]>
Date:   Tue Jun 9 23:08:12 2020 +0100

    Avoid shadowing 'type' builtin
    
    A001 "type" is a python builtin and is being shadowed, consider renaming the variable


Diff:
---
 .flake8           |  2 +-
 calm/hint.py      |  8 ++++----
 calm/pkg2html.py  | 12 ++++++------
 requirements.txt  |  1 +
 test/test_calm.py |  6 +++---
 5 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/.flake8 b/.flake8
index 8b0a9b0..81548f7 100644
--- a/.flake8
+++ b/.flake8
@@ -1,3 +1,3 @@
 [flake8]
-ignore=E741,E129,W504
+ignore=E741,E129,W504,A003
 max-line-length=240
diff --git a/calm/hint.py b/calm/hint.py
index 01ef085..5b4935b 100755
--- a/calm/hint.py
+++ b/calm/hint.py
@@ -224,17 +224,17 @@ def hint_file_parse(fn, kind):
                     if key not in hintkeys[kind]:
                         errors.append('unknown key %s at line %d' % (key, i))
                         continue
-                    type = hintkeys[kind][key]
+                    valtype = hintkeys[kind][key]
 
                     # check if the key occurs more than once
                     if key in hints:
                         errors.append('duplicate key %s' % (key))
 
                     # check the value meets any key-specific constraints
-                    if (type == 'val') and (len(value) == 0):
+                    if (valtype == 'val') and (len(value) == 0):
                         errors.append('%s has empty value' % (key))
 
-                    if (type == 'noval') and (len(value) != 0):
+                    if (valtype == 'noval') and (len(value) != 0):
                         errors.append("%s has non-empty value '%s'" % (key, value))
 
                     # validate all categories are in the category list (case-insensitively)
@@ -267,7 +267,7 @@ def hint_file_parse(fn, kind):
                             value = value.replace('  ', ' ')
 
                     # only 'ldesc' and 'message' are allowed a multi-line value
-                    if (type != 'multilineval') and (len(value.splitlines()) > 1):
+                    if (valtype != 'multilineval') and (len(value.splitlines()) > 1):
                         errors.append("key %s has multi-line value" % (key))
 
                     # message must have an id and some text
diff --git a/calm/pkg2html.py b/calm/pkg2html.py
index 3750e81..4840734 100755
--- a/calm/pkg2html.py
+++ b/calm/pkg2html.py
@@ -408,14 +408,14 @@ def write_arch_listing(args, packages, arch):
 
     for p in packages:
 
-        dir = os.path.join(base, p)
-        ensure_dir_exists(args, dir)
+        dirpath = os.path.join(base, p)
+        ensure_dir_exists(args, dirpath)
 
         #
         # write .htaccess if needed
         #
 
-        htaccess = os.path.join(dir, '.htaccess')
+        htaccess = os.path.join(dirpath, '.htaccess')
         if not os.path.exists(htaccess):
             if not args.dryrun or args.force:
                 with utils.open_amifc(htaccess) as f:
@@ -437,15 +437,15 @@ def write_arch_listing(args, packages, arch):
         #
         # for each tarfile, write tarfile listing
         #
-        if os.path.exists(dir):
-            listings = os.listdir(dir)
+        if os.path.exists(dirpath):
+            listings = os.listdir(dirpath)
             listings.remove('.htaccess')
         else:
             listings = []
 
         for tn, to in itertools.chain.from_iterable([packages[p].tars[vr].items() for vr in packages[p].tars]):
             fver = re.sub(r'\.tar.*$', '', tn)
-            listing = os.path.join(dir, fver)
+            listing = os.path.join(dirpath, fver)
 
             # ... if it doesn't already exist, or --force --force
             if not os.path.exists(listing) or (args.force > 1):
diff --git a/requirements.txt b/requirements.txt
index f7e4f65..2363fcf 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,6 +2,7 @@ dirq
 flake8
 flake8-blind-except
 flake8-bugbear ; python_version >= "3.5"
+flake8-builtins
 flake8-import-order == 0.14.1
 lockfile
 pycodestyle
diff --git a/test/test_calm.py b/test/test_calm.py
index 8c926bf..b1b82b4 100755
--- a/test/test_calm.py
+++ b/test/test_calm.py
@@ -96,14 +96,14 @@ def capture_dirtree(basedir):
 # (a dict, with lines ordered, rather than OrderedDict repr)
 #
 
-def patched_pprint_ordered_dict(self, object, stream, indent, allowance, context, level):
+def patched_pprint_ordered_dict(self, obj, stream, indent, allowance, context, level):
     write = stream.write
     write('{')
     if self._indent_per_level > 1:
         write((self._indent_per_level - 1) * ' ')
-    length = len(object)
+    length = len(obj)
     if length:
-        items = list(object.items())
+        items = list(obj.items())
         self._format_dict_items(items, stream, indent, allowance + 1,
                                 context, level)
     write('}')
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.