Giter VIP home page Giter VIP logo

black-playground's Introduction

black-playground's People

Contributors

ambv avatar dependabot[bot] avatar expectocode avatar hassanabouelela avatar hauntsaninja avatar ichard26 avatar jpadilla avatar lgeiger avatar nickpresta avatar roeladriaans avatar synap5e avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

black-playground's Issues

CORS error at https://black.now.sh/

This was reported by someone in #python IRC and I was able to reproduce; just watch the console and type something into the editor on the left of the page to trigger it trying to format.

From the console:

XHR OPTIONS https://1rctyledh3.execute-api.us-east-1.amazonaws.com/dev CORS Missing Allow Origin
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://1rctyledh3.execute-api.us-east-1.amazonaws.com/dev. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://1rctyledh3.execute-api.us-east-1.amazonaws.com/dev. (Reason: CORS request did not succeed).
Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource. commons.42e0953ff2642a53a4aa.js:6:2214

Also the "Report an Issue" link is not working.

AAAA + IPv6 for https://black.now.sh/

First of all, thanks for the awesome tool for the black demo.

How hard would it be to add IPv6 to the Hostname for us people who use IPv6 only? If it costs extra and you're paying for this yourself I understand.

  • Maybe add a donation page? (if it does - I have no idea of aws costs)

Thanks - happy to help with any IPv6 questions,
Cooper

500: INTERNAL_SERVER_ERROR

The website is down

To Reproduce

Open the website

The resulting error is:

500: INTERNAL_SERVER_ERROR
Code: FUNCTION_INVOCATION_FAILED
ID: lhr1::frs25-1645277178676-0769820ef994

Expected behaviour

The website opens

Environment

Black's version: [main]
OS and Python version: Windows, all Python Versions

Additional context

This Serverless Function has crashed.

The connection is working correctly.

Vercel is working correctly.

Python 3.8 syntax not supported

E.g. f"{test=}" fails with cannot use --safe with this file; failed to parse source file. AST error message: invalid syntax (<unknown>, line 1) when black does support it.

playground give different result from local (default configuration)

edit I figured it out, the playground black defaults to line length 60. Can you default it to 88?


https://black.now.sh/?version=stable&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4AB_AGZdAD2IimZxl1N_WmBpTZ-5BIi6_g1dz5OT0XGd6ltlrgY8lNBBz6EJ1BDNBpMW0snsYmFuZ3TfuKsnXM2a1h5wNe_-QZte1Owjq8W28N2AqQyc-bBVRSdn1EFbrFvzIvmXyx21tCRrAAAAAP-g9_g4XFe-AAGCAYABAACylNZBscRn-wIAAAAABFla

I had

my_value = my_dict[k]  # this is an inline comment on a long line

playground formatted it to this (eww)

my_value = my_dict[
    k
]  # this is an inline comment on a long line

but local version v19.10b0 with default configuration left it alone

Double spaces add a full stop

Love the playground!

Just noticed that when I double space in the playground it inserts a full stop for me, which makes the python unparsable.

e.g.
start with any bit of text

a = 1

hit the space bar twice at the end of the text and observe a space being added in

a = 1.

(n.b. it doesn't get added if on an empty line)

There's probably some default setting that assumes we're writing a sentence and tries to add the full stop for convenience, so hopefully it can be turned off 😄

Empty lines get removed when they shouldn't be

If I paste code into the playground, sometimes empty lines get removed. It seems to have to do with the Windows-style line endings.

Here's a broken example. Here's a the same code, but it works fine. As someone helpfully pointed out on discord, the broken example has Windows-style line-endings (if True:\r\n foo\r\nbar\r\n), while the working one dosn't (if True:\n foo\n\nbar\n).

On Windows, can be reproduced by copying the text from working example into notepad.exe and back. Also, I'm being told that this is not an issue with Black on command line.

String quote normalization option is inverted

Only when Don't normalize string quotes or prefixes is checked does it normalize the quotes, performing the opposite function from what it claims. This is occurring on both my computer and network as well as a friend on a different computer and network.

Either the option name needs to be changed or the function needs to be inverted.

Could --fast be either no longer used or configurable?

Hi,

Before I get to the main part of this issue, I just want to say thank you! 🎉 for making and maintaining the Black playground! Who knows how many new users of Black were introduced through your lovely website. It's also very useful for bug reporters of Black since we ask if the bug they're reporting still exists on master. Same thing for folks like me, Black triagers. It's really handy for when you don't want to or can't setup a local Black environment for testing. Ok, okay, let's get on with the issue:

I have a suggestion to make my life and the lives of other Black bug reporters/contributors. Unfortunately it appears that whatever instance of Black this website is using has been configured to run with --fast always. This example proves this as the result is showed to the user, while with any local installation of Black using its default of --safe would have failed with an AST equivalence error. This is a problem for all bug filers and especially the ones who are filing unstable formatting errors. If the filer is reporting a ASTs are not equivalent internal error when they test on master using this website, the error won't show up. This might lead them into incorrectly believing the bug is fixed on master when in reality it isn't. And the unstable formatting errors, they will never show up on this website since --fast causes that check to be skipped. Both of these issues are due to --fast being used.

And this isn't just in theory, there are real examples where this caused a bit of confusion for everyone. Here's two: psf/black#1194 and psf/black#1588.

I understand that processing power is costly for you, whether you're using a local machine where you pay for energy and do maintenance or a web service that is paid. While I would love to have --safe as the default (and I don't care if --fast could be accessed or not), I would be also happy with --safe/--fast being toggleable.

So what do you think?

Thanks once again, a Black triager.

Stable fails until preview is toggled off and on

Hi! We've encountered a slight issue with the playground, most probably due to #64. This was reported in psf/black#3145.

The playground expects a nonexistent boolean when something is formatted with the stable branch for the first time: link. This only happens via a link, so I suspect that the state has something to do with it. Using version=main instead does not produce the error. This is also fixed by toggling preview on and off again.

Is this maintained?

Hi there 👋

The master version is getting stuck at psf/black@cac182. This is a problem since people are submitting bug reports under the impression their bug exists on master when in fact it might not (it's actually how I discovered this issue). This is going to get worse with time, especially since we're releasing a hotfix version for 21.4b0 and then updating the stable ref very soon.

I totally understand if you can't keep this functional anymore (it's not like you're getting paid for this anyway!), I'd just like to know whether we should expect this to become functional again.

Regardless, thank you so much for all of your work in keeping this functional over the years! I'm sure it's been a great help to the Black community.

Provide master version

Hi! Thanks for the playground, useful for quick testing. It would be even more useful for reporting black bugs if there was a master version the user can select, to test snippets without installing git master locally.

Missing search box

Thank you for this playground!

When I press Control F in https://black.vercel.app/, I get the following error in the browser console:

8a28b14e.231908f119782f7cd62f.js:1 Unable to infer path to ace from script src, use ace.config.set('basePath', 'path') to enable dynamic loading of modes and themes or with webpack use ace/webpack-resolver
h @ 8a28b14e.231908f119782f7cd62f.js:1
...
8a28b14e.231908f119782f7cd62f.js:1          GET https://black.vercel.app/ext-searchbox.js net::ERR_ABORTED 404
...

Perhaps this is due to import 'ace-builds/src-min-noconflict/ext-searchbox'; missing here:

import 'ace-builds/src-noconflict/mode-python';
import 'ace-builds/src-noconflict/theme-tomorrow_night';

Use Python 3.10 in the playground

It seems like the project is still using 3.8, but it is causing some problems when experimenting with new syntax. I wonder whether we can bump it to Python 3.10?

black.now.sh failing with CORS error

If I paste any code into https://black.now.sh the right panel does not refresh.

Console logs:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://1rctyledh3.execute-api.us-east-1.amazonaws.com/dev. (Reason: CORS request did not succeed).

TypeError: NetworkError when attempting to fetch resource.

Error on match..case

No matter what settings I select in the playground, 3.10 enabled, main / stable or Enable potentially disruptive style changes that may be added to Black's main functionality in the next major release. enabled - it doesn't parse and beautify match .. case statement.

Error message:
cannot use --safe with this file; failed to parse source file AST: invalid syntax (<unknown>, line 4) This could be caused by running Black with an older Python version that does not support new syntax used in your source file.

Minimal code example:

import random

x = random.randint(1,10)
match x:
    case 1:
        print('a')
    case 2:
        print('b')
    case default:
        print('c')

Automated updates

@ambv this is my current idea...

  • Daily cron job on Travis CI
  • Check latest release via pypi/libraries.io/github releases atom feed
  • Install latest version with pipenv
  • Commit / push changes back to repo
  • now --public && now alias

Shorten share URLs by default

Currently, the URLs when trying to share a formatted file can get VERY long. This is suboptimal for sharing the links on sites or services that do not support hiding the links in any way, like Discord which is what the psf/black team now uses to communicate. (I've even seen a link exceed the 2000 character per message limit on Discord)

I propose shortening the URLs by default, possibly even just using a existing link shortener.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.