Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different code on second pass #1229

Closed
Datamance opened this issue Jan 14, 2020 · 2 comments
Closed

Different code on second pass #1229

Datamance opened this issue Jan 14, 2020 · 2 comments
Labels
C: unstable formatting Formatting changed on the second pass R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@Datamance
Copy link

There's different code on the second pass. This is with black, version 19.10b0.

my output from uname -a (though it's probably not useful here)
Darwin myhost.local 19.2.0 Darwin Kernel Version 19.2.0: Sat Nov 9 03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64

Does this bug also happen on master? To answer this, you have two options:

This bug doesn't happen on master, strangely enough.

Additional context Add any other context about the problem here.

Here's the diff from /var/folders/wt/xh46t1fx79n2xhxlx74q0t680000gn/T/blk_wbstcmcs.log:

--- source
+++ first pass
@@ -101,11 +101,13 @@
 class TypeCheckAction(Action):
     def __init__(self, option_strings: Sequence[Text], dest: Text, *args, **kwargs):
         self.type_alias = kwargs.pop("type_alias")
         super().__init__(option_strings, dest, *args, **kwargs)
 
-    def __call__(self, parser: ArgumentParser, namespace: Namespace, values, option_string=None):
+    def __call__(
+        self, parser: ArgumentParser, namespace: Namespace, values, option_string=None
+    ):
         """Acts like _Store, but does additional type checking."""
         typeguard.check_type(self.dest, values, self.type_alias)
         setattr(namespace, self.dest, values)
 
 
@@ -116,19 +118,19 @@
 
     for name, param in sig.parameters.items():
         add_argument_kwargs = _get_kwargs_from_param(param)
 
         if param.kind is Parameter.POSITIONAL_ONLY:
-            arg_names = (param.name, )
+            arg_names = (param.name,)
         elif param.kind is Parameter.KEYWORD_ONLY:
             arg_names = (f"--{param.name}",)
         elif param.kind is Parameter.VAR_POSITIONAL:
-            arg_names = ('-k', '--kwarg', f"--{param.name}")
+            arg_names = ("-k", "--kwarg", f"--{param.name}")
             add_argument_kwargs["nargs"] = 2
             add_argument_kwargs["action"] = "append"
         elif param.kind is Parameter.VAR_KEYWORD:
-            arg_names = ('-k', '--kwarg', f"--{param.name}")
+            arg_names = ("-k", "--kwarg", f"--{param.name}")
             add_argument_kwargs["nargs"] = 3
             add_argument_kwargs["action"] = "append"
         elif param.kind is Parameter.POSITIONAL_OR_KEYWORD:
             # TODO: Can we make positional args an option as well?
             # parser.add_argument(param.name, **add_argument_kwargs)
@@ -157,11 +159,13 @@
         else:
             kwarg_dict["action"] = "store_true"
     elif param.annotation is list:  # Assume it's a list of strings.
         kwarg_dict["type"] = str
         kwarg_dict["nargs"] = "*"
-    elif base_type := getattr(param.annotation, "__origin__", None) is list:  # It's a typing construct
+    elif (
+        base_type := getattr(param.annotation, "__origin__", None) is list
+    ):  # It's a typing construct
         kwarg_dict["action"] = TypeCheckAction
         kwarg_dict["type"] = param.annotation.__args__[0]
         kwarg_dict["type_alias"] = param.annotation
         kwarg_dict["nargs"] = "*"
     elif base_type is dict:
--- first pass
+++ second pass
@@ -161,11 +161,11 @@
     elif param.annotation is list:  # Assume it's a list of strings.
         kwarg_dict["type"] = str
         kwarg_dict["nargs"] = "*"
     elif (
         base_type := getattr(param.annotation, "__origin__", None) is list
-    ):  # It's a typing construct
+    ) :  # It's a typing construct
         kwarg_dict["action"] = TypeCheckAction
         kwarg_dict["type"] = param.annotation.__args__[0]
         kwarg_dict["type_alias"] = param.annotation
         kwarg_dict["nargs"] = "*"
     elif base_type is dict:
@Datamance Datamance added the T: bug Something isn't working label Jan 14, 2020
@ichard26
Copy link
Collaborator

ichard26 commented Oct 5, 2020

Looking at the log this looks like #1588 and therefore should be fixed by #1655. Please note that the bugfix is currently unavailable in any release.

@ichard26 ichard26 added the C: unstable formatting Formatting changed on the second pass label Jan 16, 2021
@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label Apr 25, 2021
@ichard26
Copy link
Collaborator

Yep, definitely fixed by GH-1655. Closing before I forget again. The bugfix should be available in a published release soon, see GH-2125 more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: unstable formatting Formatting changed on the second pass R: duplicate This issue or pull request already exists T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants