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 #4316

Closed
JuanPerdomo00 opened this issue Apr 20, 2024 · 1 comment
Closed

INTERNAL ERROR #4316

JuanPerdomo00 opened this issue Apr 20, 2024 · 1 comment
Labels
T: bug Something isn't working

Comments

@JuanPerdomo00
Copy link

error: cannot format checkgo.py: INTERNAL ERROR: Black produced code that is not equivalent to the source.

import re
import requests
import platform
from cansii import CAnsii as c






def banner_gopher():
    return c.blue(
    """

         ,_---~~~~~----._         
  _,,_,*^____      _____``*g*""*, 
 / __/ /'     ^.  /      \\\\ ^@q   f 
[  @f | @))    |  | @))   l  0 _/  
 \\`/   \\\\~____ / __\\\\_____\\\\    \\\\   
  |           _l__l_           I   
  }          [______]           I  
  ]            | | |            |  
  ]             ~ ~             |  
  |                            |   
   |                           |  
"""
)


# Plataformas a la cual se podran descargar
PLATFORM = {
    "Darwin", # MacOs
    "Windows",# NT
    "Linux", # :)
    "Source"
}



class Checkgo:
    @classmethod
    def _check_platform(cls):
        for_linux = platform.platform().split("-")[0]
        if for_linux in PLATFORM:
            return "linux"
        # Asi con los demas que faltan, por falta de equipos
        # no podre testearlos, por ahora solo en linux
        # ...
    
    @classmethod
    def download_go_version(cls, version):
        """Descarga le version de golang expecificada

        Args:
            version que llega desde get_latest_go_version
        """
        
        dl_url = f"https://go.dev{version}"
        filename = f"Checkgo-{version.split("/")[-1]}"
        try:
            response = requests.get(dl_url)
            response.raise_for_status()
            with open(filename, "wb") as f:
                f.write(response.content)
            print(
                f"¡La versión {version} de Go se ha descargado con éxito como {filename}!"
            )
        except requests.RequestException as e:
            print(f"Error al descargar la versión {version} de Go:", e)

    @classmethod
    def get_latest_go_version(cls):
        url = "https://go.dev/dl/"
        try:
            plataforma = cls._check_platform()
            response = requests.get(url)
            response.raise_for_status()
            # Utilizar expresiones regulares para extraer los enlaces de descarga
            match = re.findall(r'href="(/dl/go\d+\.\d+\.\d+\.%s-amd64\.tar\.gz)"' % plataforma, response.text)
            if match:
                latest_version = match[0]
                print("Última versión encontrada:", latest_version)
                return latest_version
            else:
                print("No se pudo encontrar la última versión de Go.")
        except requests.RequestException as e:
            print("Error al obtener la última versión de Go:", e)

def main():
    latest_version = Checkgo.get_latest_go_version()
    if latest_version:
        print("Última versión de Go:", latest_version)
        Checkgo.download_go_version(latest_version)

if __name__ == "__main__":
    main()

And run it with these arguments:

$ black file.py --target-version py39

The resulting error is:

[ cannot format file.py: INTERNAL ERROR: ...](error: cannot format checkgo.py: INTERNAL ERROR: Black produced code that is not equivalent to the source. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: /tmp/blk_1v6_6j0v.log)

Expected behavior

Environment

  • black, 24.4.0 (compiled: yes)
  • Python 3.12.2 Red Hat 13.2.1-6 linux

Additional context

@JuanPerdomo00 JuanPerdomo00 added the T: bug Something isn't working label Apr 20, 2024
@hauntsaninja
Copy link
Collaborator

Duplicate of #3746 (nested same type quotes in f-strings is only valid syntax in Python 3.12 and newer)

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants