#53 spectool: code cosmetics and use black (with --line-length 100)
Merged 3 years ago by ngompa. Opened 3 years ago by decathorpe.
Unknown source master  into  master

file added
+2
@@ -0,0 +1,2 @@

+ [tool.black]

+ line-length = 100

file modified
+13 -30
@@ -57,8 +57,7 @@

          argcomplete = None

  

      parser = argparse.ArgumentParser(

-         description=HELP_TEXT,

-         formatter_class=argparse.RawDescriptionHelpFormatter,

+         description=HELP_TEXT, formatter_class=argparse.RawDescriptionHelpFormatter,

      )

  

      ops = parser.add_argument_group("Operating mode")
@@ -103,35 +102,19 @@

      )

  

      files.add_argument(

-         "--sources",

-         "-S",

-         action="store_const",

-         const=True,

-         default=False,

-         help="all sources",

+         "--sources", "-S", action="store_const", const=True, default=False, help="all sources",

      )

  

      files.add_argument(

-         "--patches",

-         "-P",

-         action="store_const",

-         const=True,

-         default=False,

-         help="all patches",

+         "--patches", "-P", action="store_const", const=True, default=False, help="all patches",

      )

  

      files.add_argument(

-         "--source",

-         "-s",

-         action="store",

-         help="specified sources",

+         "--source", "-s", action="store", help="specified sources",

      )

  

      files.add_argument(

-         "--patch",

-         "-p",

-         action="store",

-         help="specified patches",

+         "--patch", "-p", action="store", help="specified patches",

      )

  

      misc = parser.add_argument_group("Miscellaneous")
@@ -189,10 +172,7 @@

          help="output debug info, don't clean up when done",

      )

  

-     specfile = parser.add_argument(

-         "specfile",

-         action="store",

-     )

+     specfile = parser.add_argument("specfile", action="store")

  

      if argcomplete:

          specfile.completer = complete_spec_paths
@@ -204,7 +184,7 @@

  

  

  def split_numbers(args: str) -> list:

-     return list(arg for arg in args.split(","))

+     return args.split(",")

  

  

  def get_file(url: str, path: str, force: bool) -> bool:
@@ -336,6 +316,7 @@

  

      if args["debug"]:

          import pprint

+ 

          print("Parsed command line arguments:")

          pprint.pprint(args)

  
@@ -409,9 +390,11 @@

          if args["directory"]:

              directory = args["directory"]

          elif args["sourcedir"]:

-             ret = subprocess.run(["rpm", "--eval", "%{_sourcedir}"],

-                                  stdout=subprocess.PIPE,

-                                  stderr=subprocess.STDOUT)

+             ret = subprocess.run(

+                 ["rpm", "--eval", "%{_sourcedir}"],

+                 stdout=subprocess.PIPE,

+                 stderr=subprocess.STDOUT,

+             )

              ret.check_returncode()

              directory = ret.stdout.decode().strip()

          else:

  • replaces list(arg for arg in args.split(",")) with just args.split(",")
  • reformatted code with black -l 100 (88 is too short!)

Could you add a pyproject.toml file that configures black for this?

rebased onto 7e3d9b9

3 years ago

Pull-Request has been merged by ngompa

3 years ago
Metadata