jpadilla / black-playground Goto Github PK
View Code? Open in Web Editor NEWpsf/black online demo
Home Page: https://black.vercel.app
License: MIT License
psf/black online demo
Home Page: https://black.vercel.app
License: MIT License
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')
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:
black-playground/web/components/editor.js
Lines 4 to 7 in c662c7f
Currently the line length documentation links to: http://black.readthedocs.io/en/latest/the_black_code_style.html#line-length
This page no longer exists. The current correct documentation link seems to be: https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
Thanks for making this!
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.
https://black.now.sh/ is giving a 500 internal server error.
Not usable.
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 😄
Hi! Firstly, thanks for the playground, I use it all the time 🙏 Since introducing the stability policy and --preview
toggle in 22.0, we can no longer see the bleeding edge style with playground.
It'd be nice to have a toggle for --preview
in the options!
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.
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.
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?
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.
@ambv this is my current idea...
now --public && now alias
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.
There is currently no way to toggle the new --unstable
style added in Black 24.1.0.
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.
Thanks - happy to help with any IPv6 questions,
Cooper
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.
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.
edit I figured it out, the playground black defaults to line length 60. Can you default it to 88?
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
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.
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.
Please set the ruler (vertical line) to be after 88th character (or adapt to line length option). Thanks!
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.
It show stable
and master
version.
I want to test 19.3b0
but it doesn't support.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.