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

INTERNAL ERROR: Black produced different code on the second pass of the formatter. #1900

Closed
ccie18643 opened this issue Jan 2, 2021 · 1 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

Comments

@ccie18643
Copy link

ccie18643 commented Jan 2, 2021

error: cannot format /root/PyTCP/fpp/icmp6.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: /tmp/blk_74vkg8wd.log

diff

(python3.8) root@ubuntu-1:~/PyTCP# cat /tmp/blk_74vkg8wd.log
Mode(target_versions=set(), line_length=160, string_normalization=True, experimental_string_processing=False, is_pyi=False)
--- source
+++ first pass
@@ -275,22 +275,34 @@
     def _read_nd_options(self, optr):
         """ Read ND options """
 
         nd_options = []
         while optr < len(self._frame):
-            nd_options.append({ps.icmp6.ND_OPT_SLLA: NdOptSLLA, ps.icmp6.ND_OPT_TLLA: NdOptTLLA, ps.icmp6.ND_OPT_PI: NdOptPI}.get(self._frame[optr], NdOptUnk)(self._frame, optr))
+            nd_options.append(
+                {ps.icmp6.ND_OPT_SLLA: NdOptSLLA, ps.icmp6.ND_OPT_TLLA: NdOptTLLA, ps.icmp6.ND_OPT_PI: NdOptPI}.get(self._frame[optr], NdOptUnk)(
+                    self._frame, optr
+                )
+            )
             optr += self._frame[optr + 1] << 3
 
         return nd_options
 
     @property
     def nd_options(self):
         """ Read ND options  """
 
         if self.__nd_options is self.__not_cached:
             assert self.type in {ps.icmp6.ROUTER_SOLICITATION, ps.icmp6.ROUTER_ADVERTISEMENT, ps.icmp6.NEIGHBOR_SOLICITATION, ps.icmp6.NEIGHBOR_ADVERTISEMENT}
-            optr = self._hptr + {ps.icmp6.ROUTER_SOLICITATION: 12, ps.icmp6.ROUTER_ADVERTISEMENT: 16, ps.icmp6.NEIGHBOR_SOLICITATION: 24, ps.icmp6.NEIGHBOR_ADVERTISEMENT: 24}[self.type]
+            optr = (
+                self._hptr
+                + {
+                    ps.icmp6.ROUTER_SOLICITATION: 12,
+                    ps.icmp6.ROUTER_ADVERTISEMENT: 16,
+                    ps.icmp6.NEIGHBOR_SOLICITATION: 24,
+                    ps.icmp6.NEIGHBOR_ADVERTISEMENT: 24,
+                }[self.type]
+            )
             self.__nd_options = self._read_nd_options(optr)
         return self.__nd_options
 
     @property
     def nd_opt_slla(self):
@@ -588,6 +600,5 @@
 
     def __eq__(self, other):
         """ Compare two records """
 
         return self.raw_record == other.raw_record
-
--- first pass
+++ second pass
@@ -290,19 +290,16 @@
     def nd_options(self):
         """ Read ND options  """
 
         if self.__nd_options is self.__not_cached:
             assert self.type in {ps.icmp6.ROUTER_SOLICITATION, ps.icmp6.ROUTER_ADVERTISEMENT, ps.icmp6.NEIGHBOR_SOLICITATION, ps.icmp6.NEIGHBOR_ADVERTISEMENT}
-            optr = (
-                self._hptr
-                + {
-                    ps.icmp6.ROUTER_SOLICITATION: 12,
-                    ps.icmp6.ROUTER_ADVERTISEMENT: 16,
-                    ps.icmp6.NEIGHBOR_SOLICITATION: 24,
-                    ps.icmp6.NEIGHBOR_ADVERTISEMENT: 24,
-                }[self.type]
-            )
+            optr = self._hptr + {
+                ps.icmp6.ROUTER_SOLICITATION: 12,
+                ps.icmp6.ROUTER_ADVERTISEMENT: 16,
+                ps.icmp6.NEIGHBOR_SOLICITATION: 24,
+                ps.icmp6.NEIGHBOR_ADVERTISEMENT: 24,
+            }[self.type]
             self.__nd_options = self._read_nd_options(optr)
         return self.__nd_options
 
     @property
     def nd_opt_slla(self):
@ccie18643 ccie18643 added the T: bug Something isn't working label Jan 2, 2021
@ichard26 ichard26 added the C: unstable formatting Formatting changed on the second pass label Jan 3, 2021
@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label Apr 25, 2021
@ichard26
Copy link
Collaborator

Hello!

All reproduction cases in this issue format without error on master. The fixing commit was 8672af3 from PR GH-2126. I'll be marking this issue as a duplicate of GH-1629 since that's what GH-2126 aimed to fix and it's highly likely this issue falls under GH-1629.

Since we use the issue tracker as a reflection of what's on master, I'll be closing this issue. If you have any issues, especially with the new (but stable) output, please open a new issue. Oh and the fix should be available in a published release soon, see GH-2125 for more info.

Thank you for reporting!

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