Created
          July 25, 2025 12:15 
        
      - 
      
 - 
        
Save mgaitan/7052bbe00c2cc88f8771b576c36665ae to your computer and use it in GitHub Desktop.  
    A demo script for autopep723 blog post. Look mom, just plain imports!
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import httpx | |
| from pyfiglet import Figlet | |
| from rich.console import Console | |
| from rich.text import Text | |
| def gradient(text, start=(255, 0, 0), end=(0, 255, 255)): | |
| lines = text.splitlines() | |
| width = max(len(line) for line in lines) | |
| grad = [( | |
| int(start[0] + (end[0] - start[0]) * i / (width - 1)), | |
| int(start[1] + (end[1] - start[1]) * i / (width - 1)), | |
| int(start[2] + (end[2] - start[2]) * i / (width - 1)) | |
| ) for i in range(width)] | |
| grad_hex = [f"#{r:02x}{g:02x}{b:02x}" for r, g, b in grad] | |
| out = Text() | |
| for line in lines: | |
| for i, c in enumerate(line.ljust(width)): | |
| out.append(c, style=grad_hex[i]) | |
| out.append("\n") | |
| return out | |
| ascii_art = Figlet(font="slant").renderText("autopep723 rocks!") | |
| console = Console() | |
| console.print(gradient(ascii_art)) | |
| console.print("\n".join([v for k, v in httpx.get("https://v2.jokeapi.dev/joke/Programming").json().items() if k in ("joke", "setup", "delivery")])) | 
      
      
  Author
  
  
      
          
      
      
            mgaitan
  
      
      
      commented 
        Jul 25, 2025 
      
    
  
    
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment