#black-formatter
1 messages Β· Page 14 of 1
Currently, Black uses a vendored version of lib2to3 for parsing. This works well for parsing Python 2 and early Python 3, but Python has now moved on to a PEG-based parser (PEP 617), and lib2to3 is no longer being maintained.
So we need a new parser. There are a few existing options that we could leverage (Parso, LibCST), but it's going to be a lot of work to do the migration. WE're d...
there you go
I'm in roughly the same boat as Jelle, but I did spent a few hours somewhat recently in this specific part of the codebase trying to fix a bug (I wasn't successful) and this looks good to me as well.
Thank you for the PR! It's awesome to see one bug fixed.
40fae18 Possible fix for issue with indentation and fmt... - enzet
Looking good!
I was going to suggest adding how Black tries extra hard for certain pragma comments to avoiding them, but I ended up deciding against it because it's not a guarantee so not exactly useful to readers :P (also it's mentioned in the linked AST safety section anyway)
Thanks a million!
@dense jungle do you want to do a quick lookover for the above docs PR or are happy with it (and I'll merge if so)?
whelp that's my answer lol.
I think it's good to go
hm, no checks passed/failed webhook sending?
I think the service that's handling the communication between GH and this channel is filtering that sort of messages out
ah, it isn't being sent directly to a discord webhook then?
That would be way too noisy since there's pretty much no filtering configuration on their side
You get to choose "no webhook", "push events", or "or let me know of everything" IIRC
yeah, that's not handled in the worker source @plain atlas, that's just disabled in the repo π
Well it turns out I was wrong on the last option, but overall, you don't get much choice π
ah lol
yeah, i agree.
could you tell me how the workers work in #ot2-the-original-pubsta?
Completely OT but I'm developing the ability to just know where to add line breaks in the little commit message box GitHub gives you when merging. I managed to nail the 72 character rule of thumb without checking somehow.
OK, so before we release, here's my list of PRs we might consider landing first:
- https://github.com/psf/black/pull/2301 (Switch toml TOML library for
tomli) - https://github.com/psf/black/pull/2285 (Regression fix: leave R prefixes capitalization alone)
- https://github.com/psf/black/pull/2297 (Normalise string prefix order)
I think 2 is safe to land (although it needs a review), 1 might be okay although I have no real experience in this area, and 3 seems like it's awaiting discussion on our support policy for Python 2.
Although it definitely could be possible 3 is OK and I just managed to miss all of the relevant discussion. IIRC Cooper said they wanted to get it in.
Thank you for the review @dense jungle !
It is ok, but myself and Jelle would prefer r first, which imo could be reason to wait until Py2 is removed to avoid special cases
Fixes #1468 (or at least the issue that's in the comment there)
Not an awfully big amount of tests added here but I'm not sure if there's a need for more.
Sooo after trying to contribute I've noticed some small issues with local testing:
pre-commit run --all-filesfails becausesrc/black/output.pyhas one line that exceeds the line length- perhaps this command should be included in CI to stop a PR that would break this requirement? This was it wouldn't affect a contributor who hasn't actually done anything wrong.
tox -e pyis failing on the optionalno_python2test when I run it locally. I followed the contributing guide (the pipenv way) from Black's docs (https://black.readthedocs.io/en/stable/contributing/the_basics.html) before I was running any testing so the way I installed shouldn't be a problem? perhaps something causes the typed-ast dependency to be installed? Testing on Windows
I ignored both of these since I knew neither of these problems were caused by me but I just wanted to share some feedback as first-time contributor
Yeah, Windows has had some issues π If you'd be so kind, Richard has created a dedicated issue for the contributing experience: psf/black#2238 Would be great to add this in! (and don't worry, I'll add it later if you haven't yet)
I'll add later if I don't forget lol
Or I could, just copy-paste now I guess
Done, thanks for linking the right place to put it on
Hi, thanks for submitting! I'm not familiar with this part of the code base so take it with a grain of salt, but I left some thoughts below. I'd like for the more experienced maintainers to take a look too.
Hmm which line is exceeding the limit? I just ran pre-commit on master and it passed
It should also be passing in master, there's already a CI action for it
https://github.com/psf/black/blob/main/.github/workflows/lint.yml
Ξ» pre-commit run --all-files
black....................................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1
src/black/output.py:48:92: B950 line too long (91 > 80 characters)
mypy.....................................................................Passed
prettier.................................................................Passed
Could you try running pipenv run flake8 in the root directory?
Ah is it another case of psf/black#2299
Sorta, my best guess is it isn't using the correct flake config
We've run into this a lot in #dev-contrib because our setup has a ton of plugins, and people would usually be running their own flakes without them
Hmm not sure that's it anymore. I couldn't repro it
I tried with 39
It does say that the line length limit is 80 though
So something's fishy. Any updates @lament crow?
But now that I think about it, I don't think I've had problems running other than Black with precommit even though I have basically nothing installed on the system interpreter
And the linked issue was about not finding black..
running pipenv run flake8 in root is wrong because that runs it on tests data as well
so I've got a big wall of errors :P
a wall that is apparently so big that I'm past console's history buffer
but anyway
line length limit is 88, right?
so 91 is still past 88
88 + 10%
I should better explain
it's a bugbear thing
Oh so it doesn't show in the error, the increased line length?
well, 80+10% is 88 so however we look at it, 91 is higher
yea
for lineno, line in enumerate(self.lines, start=1):
length = len(line) - 1
if length > 1.1 * self.max_line_length:
yield B950(lineno, length, vars=(length, self.max_line_length))
oh, it's this comment line: https://github.com/psf/black/blob/main/src/black/output.py#L48
src/black/output.py line 48
# See https://www.gnu.org/software/diffutils/manual/html_node/Incomplete-Lines.html```
It's within line length for me though nvm, it's not
Funny enough, I can't get any length to trigger it
What other flake8 rules are there to break
but ye, this one is not going to work correctly because .flake8 does not have the excludes set
only pre-commit config does
(does discord have strikethrough MD?)
~~something~~
not that this is the issue here
yeah the line is longer than it should
I'm proper confused now :D after removing .flake8 I can lint the file and it does complain
do you run flake8 with cwd of the project root?
Ah, E501 is the very line len error that is ignored in the config
Yep, for some reason it doesn't trigger
the difference in this was the exclusion
Exclusion of E501 in .flake8
huh
I think it's time to MWE this up :D
Hmm
do you have a clean environment to test bugbear?
If so, do you get any errors on this:
class Test:
def abc(xyz):
pass
This should in theory be failing, but I can't get it to fail
Yeah that fails
Does it fail in black
No!
Also I couldn't repro the line length issue alone
Even when straight up copying the file
Seems bugbear isn't working at all
Completely lost at what is going on really but does flake8 even recognize bugbear?
Does flake8 --version include bugbear?
yup
3.9.2 (flake8-bugbear: 21.4.3, mccabe: 0.6.1, pycodestyle: 2.7.0, pyflakes: 2.3.1) CPython 3.9.4 on Windows
OK that's the end of me being useful since I'm on my phone π
The interesting thing would be why did it work for Jackenmen then
ye, I do find it interesting it only works for me lol
actually, I'm gonna check one thing in a sec
Normally it's the bug that can't be reproduced, not the other way around :D
ye, I found the reason it works differently for me
I do have a "global" flake8 config
since if a project doesn't have one, I like to have sensible defaults
[flake8]
max-line-length = 88
select = B,C,E,F,W
ignore = E203, W503
Yeah..
extend-ignore seems to be what's causing the issues here
like, if you replace it with ignore then it works fine (as in, fails) in CI
But it doesn't ignore any bugbear errors π€
Bugbear's opinionated warnings require explicit selection.
so perhaps it doesn't work well with extending smh
perhaps bugbear in some way adds into the default ignores
I did, bugbear still fails for me
only thing that matters is the ignore
if I remove that from mine, then it works
Black's ignore you mean?
mine
right
if you replace Black's extend-ignore with ignore then it also works so it's really something about the extending working in unexpected way
So for some reason the extend-ignore is handled in some odd ways
Yeah
YAY a reproduction!
Paste your config in a fresh environment, then call flake8 file.py --extend-ignore=E501
And actually, having an empty configuration named .flake8 and calling like above produces that same situation, whereas without it bugbear errors are still selected
I'm confused, did you reproduce it yourself or do you want me to do something lol
Which I'm not sure should happen either, since B9XX is opt-in if I remember correctly :D
Yeah I did
btw, this is in bugbear's code
@staticmethod
def add_options(optmanager):
"""Informs flake8 to ignore B9xx by default."""
optmanager.extend_default_ignore(disabled_by_default)
...
disabled_by_default = ["B901", "B902", "B903", "B950"]
Yeah this is just getting more complicated by the minute :D
I don't know why this default ignore doesn't actually do anything when I don't have a "global" configuration file with ignore in it but well
Do you plan on reporting that on flake's repo or should I look into it
maybe at least we will get a clearer answer lol
I think we should really nail down a list of different situations and the behaviors
Because this is confusing as hell
I'll reset my venv and start from scratch
- Install flake8 and flake8-bugbear
- Put this into a
~/.flake8(or%userprofile\.flake8):
[flake8]
ignore = E203, W503
- Create a simple project directory with
.flake8file:
[flake8]
max-line-length = 80
extend-ignore = E203, E266, E501
select = B,C,E,F,W,T4,B9
- Make a
test.pyfile:
# very long comments, which is certainly longer than 88 characters which is what bugbear should error on
- Run
flake8 - See results (or rather, lack of any)
now that I wrote this, I need to actually see if I can reproduce it like that :D
oh wait, it was the other way around, right
so it's not a bug
because bugbear extend default ignores
which you guys extend further
so it's black's config fault after all, yay
I have to go for some time but I'll get back to this
Or I'll have to go soon, but in the meantime I can't get flake8 alone to complain about line length
flake8 alone, you mean without bugbear?
yeah...
are you ignoring E501
nowhere, also explicitly selecting every error
oh right
pycodestyle is disabled by default
from bugbear's readme:
Note that pycodestyle also has a bunch of warnings that are disabled by default. Those get enabled as soon as there is an ignore = line in your configuration.
:D
Yeah, flake8 file.py --select=C,E,F,W does nothing
what.
what what
flake8 file.py --select=C,E,F,W --ignore=E001 does work
I should have quoted more:
I think this behavior is surprising so Bugbear's opinionated warnings require explicit selection.
YE, I think it's surprising too!
Yeah, but I'm still on the flake8 only errors :D
I'd expect selecting the damn errors is enough
ignore takes priority over select
Maybe I'm just confused, if I'm ignoring nothing, shouldn't and explicit --select=E select all E-class errors :D
are you ignoring nothing though?
because not saying you ignore something equals ignoring defaults
confusing, I know :D
I'm not going to say it's dumb because I'm sure there must have been some reason to do it that way
but I sure can say it's confusing the hell out of me lol
so basically, you guys need to use regular ignore or else you run into surprising behaviors of flake8
I'll look into making a PR considering I already spent time on this anyway lol
Yeah that would be much appreciated
and I'm still thoroughly confused, looks like I will have to read over this chat a few times over at least
Having the extends is convenient, but I guess it's better to enforce a list, people can then extend on the command line
anyway, great work y'all
Basically, bugbear's B9 checks (and possibly other checks that you possibly want to run) weren't actually running due to the use of extend-ignore.
Describe the bug
INTERNAL ERROR: Black produced different code on the second pass of the formatter.
The first bad commit is https://github.com/psf/black/commit/586d24236e6b57bc3b5da85fdbe2563835021076 according to git bisect.
To Reproduce
Take this file:
def test(self, othr):
return (1 == 2 and
(name, description, self.default, self.selected, self.auto_generated, self.parameters, self.meta_data, self.schedule) ==
(name, description,...
Yeah not much to say, checks out!
π I just noticed that your changelog entry check doesn't duplicate despite having label as an event
did GitHub finally fix it :o
In my opinion this looks much better now, thanks a ton for being so speedy to modify!
I wonder why it was using extend in the first place
It was slipped in to this commit, but it isn't mentioned
https://github.com/psf/black/commit/573b8de54470dbad8bcaaebd5a28dad507c44666
For CLI usage I would imagine
Would that be something not worth keeping then?
I mean, ignore in config and extend in CLI is functionally similar to extend in config and ignore in CLI
What's been done seems like the best solution currently possible, but it seems the most ideal solution would be getting flake8(-bugbear) to support extend
Alright, sounds good
Everything looks good. Crazy this has gone unnoticed for so long.
229498e Fix flake8 configuration by switching from exte... - jack1142
On a slightly different note, does anyone review PSF projects locally? I wasn't able to submit my review due to oauth apps restrictions
gh cli?
You mean using the Github app or something? I only use the website
pycharm, but I imagine the cli would suffer from the same thing
Error occurred while submitting a review
Although you appear to have the correct authorization credentials, thepsforganization has enabled OAuth App access restrictions, meaning that data access to third-parties is limited. For more information on these restrictions, including how to enable this app, visit https://docs.github.com/articles/restricting-access-to-your-organization-s-data
you could use a PAT instead of oauth authentication as a workaround
That would probably work, but pycharm signs out on restart, which would mean generating a new token every time I start it up
I would tell you to just make an oauth app request, I would assume nobody's going to come to your home and murder you for it, maybe they just won't accept :)
Hahaha
Anyways, it's just clicking the submit button that needs to be done on site, so it's probably not a big deal
Oh, I take that back
Describe the bug
Format failure due to non-equivalent code to the original, probably because of replacing tab with spaces inside a doc-string.
To Reproduce
- create a file
something.py - paste the content:
def foo() -> None: """ Some documentatios: 'serialization.format' = ' ', """ pass - run
black something.py - observe error like:
error: cannot format something.p...
looks like they did fix it indeed, but I ran into another problem which makes it unsuitable for my use case :(
Wow - much activity
What are we waiting for @neon loom in terms of new release?
Or are you hoping I know so I can let you know so we do a release?... cause in that case, I don't exactly know. psf/black#2319 seems OK but I have no real skills in this area of the codebsae.
Yeah it seems to be okay, my last comment can be ignored for now
Iβve just been waiting for a slow down in action to draw the lone in the same personally
lol
*line in the sand
blame the apple
it's not "an apple keeps the doctor away", it's actually "an apple causes a breakout of typos"
Named escapes could be good since it's related to the string processing
(for context, cooper has an iphone)
Oh right, I think that's Jack's first contribution so it's time to bust out my saved reply... Well sorta, I mean, they saw the "improving the contributing experience" issue already.
I'll just say thank you as always π
Also if you're still looking for easy wins, the AST errors just need a decisive mypy guru ;) but the impact is minimal though psf/black#2304
TBH, I've been hesitant since I may end rewriting the whole the module during my mypyc work.
Oh!
But it's not 100% likely so I'll merge I guess.
Honestly I'm a fan of asserts for this sort of things.
Yeah consider it done, gimme a minute
I was just gonna check it out and do the changes myself and push but that also works π
My GitHub Notifications are always a mess, I can never keep my inbox empty π
Someone once told me βselect all -> mark readβ, and get a fresh start
Ofc I didnβt but oh well
"View all 164 notifications" - oh how fun
I watch two repositories and have a bad habit of not clicking "done".
Oh actually, the assert doesn't work, so should we go with the test instead?
It's psf/black and pypa/bandersnatch by the way.
Wait what
............
Yeah fun
So maybe we'll go with that since you're already working on it and type: ignore seems kinda bad
pushed
happy to help, was honestly more fun than I thought it will be
and you're no match to me π¬
I get email notifications and I kinda don't have time to mark those as done on GitHub
Ooo I wonder if typeshed's overloads for ast.parse don't have version based conditionals
But how would that change assert vs if? π€
actually let's just move on, I don't know what I am saying π
yeah typeshed does have the version based conditionals anyway
wonder why the assert doesn't work then
Yeah seems weird since it's equivalent in the code flow
Cooper has apple everything basically. Not home pods or HomeKit crap tho.
So we trying to get that 1 more PR in for the push? I think I'm gonna merge my own primer STDIN as it hurts nothing, is fast and might catch something one day ...
Are there two coopers?
or was that third person?
very much third person I believe
Ah, aru is sorry he didn't understand. π
Yup checks passed! Feel free to mrrg
Richard hates your usage of third person /s
Felix just passed checks
That sounds like Felix was sus for something out of context π
All the checks: health, IQ, not-a-pedo, you name it
Uhh, strange reference but OK
Purple name, check
Too far, check
Contributor of black, check
Aha same
It's like saying "I'm no criminal...", sounds suspicious doesn't it :p
:D trust me, I'm trustworthy
What is acting responsible?
My code definitely follows pep 8
And follows black too
Definitely 100%
I'd never write code in a different style ever
Aaanyways, the thing before all this stuff: merge and then release?
Oops sorry for derailing the channel lol
I certainly without a shred of doubt am the most qualified person to lead the psf/black project. My experience goes far beyond the skyline into outer-space. My knowledge runs deep, as deep as the ocean. I have the will of 1000 developers... OK that's enough of me being ridiculous lol (so much /s)
Yeah, I'm defering to @errant barn + @bright glacier to declare when release is wanted and I'll do the few clicks
Yeah, I hear @solid adder has got nothing worth giving ...
Sounds like the beginning of a copy pasta lmao
returns to $dayJob painful work
So black will be releasing as stable eventually?
Ah, whew
That's not the discussion today. Today is cutting another beta release with all our fixes.
Whew :+1:
Then get experimental string formatting on by default. Then we can discuss the stable
Good, good
Hmm, the stable tag only includes changes before and on May 10th even though the newest release is from May 31st
I've been getting a bunch of these when running tox -e py

The only thing I'm not sure about with the AST PR is this:
Also, target versions include Pythons all the way from 3.3. Should they be here (and in the version list below) too?
Yeah that's fair
I initially removed them because they overlapped with the typed_ast versions 6 and 7
Damn it. Before I read it until the end I was ready to give you the nuclear codes and run away
Open a bakery in Provence
Or buy a fishing boat in the Maldives
OK that's enough silliness from me, I get seasick real easy
Ah yes. I knew changing notifications to all messages for this channel would be a bad decision. Too much fun stuff happens here, and it's distracting in a good way π
You can never have too much fun
Now that I run that exact command it happens to me as well, so seems like a no-brainer. Thanks!
I am not the biggest fan of pastries tbh
that's almost as bad as using tabs for formatting
!ot unless that's somehow related to black
It's a reference to ambv's (maybe dream) of running and starting a bakery in southern france
Docker workflow is used for publishing images to DockerHub which I'm pretty sure people that just try to contribute wouldn't want and the workflow fails because the forks don't have the credentials set up. While it is set to only run on main some people like to keep their fork up-to-date and GitHub even acknowledged that recently making it extremely easy to update from the web.
This is also a...
@solid adder Still here? Could you chime in a bit to removing versions from AST parsing in psf/black#2304 I think you could be the person that knows the most about this.
Give me 15 minutes
I'm fetching a package
Whelp I'm copying and pasting for bandersnatch which quite literally is facing the exact same issue. Thanks!
actually I was wrong in that PR review
the bandersnatch issue is similar but not the same π
sometimes checking before doing something is better ay
uh--
should the docker workflow only run on pushes to main?
also iirc, to keep the ambv/black->psf/black redirect, Εukasz needs to make branches on psf/black repo and can't use the fork I suppose
unless GitHub changed something
a bit annoying that you can't choose a fork name if you ask me :P
I'm pretty sure that's current behaviour ATM still
yeah it sucks
if ambv were to ever press the fork button it will break the redirect.
because it will just fork without asking if you really meant to fork ;-;
unless you have repo creation access on a different org
Well, sorta
in that case you have a popup
true
yep!
where you have to choose where you want to fork
I considered adding a conditional to block the docker workflow from running if the test workflow fails, but I suck at conditionals so yeah no. Also, the chances of people pushing directly to main with breaking changes is low, right?
do you guys use protected branches?
Yeah seems reasonable
Nope IIRC
ah well
π
could make sense to make a dep then if someone does push stuff directly to main
Using them could be a good thing though, since we have a reasonable number of people available for review
not using protected branches is a bad idea imo
means that anyone with push access can just push to main
I agree in general. This is something Εukasz would have to configure.
Honestly our current set up means that I can make a release with only write perms
That's convenient to be fair
protected branches would obviously help but not 100% block danger
you can make github releases with just write perms anyway
e.e
that's freaky
Well I consider PyPI releases to be a lot more meaningful than GH releases π
I think it's worth bringing up with the rest of the core team later
this is a portion of the required status checks on my repo
don't your gh release workflow push to pypi?
Yes
π€¦
then you can release to pypi as well, unless you use the environments
https://docs.github.com/en/actions/reference/environments
You can configure environments with protection rules and secrets. A workflow job can reference an environment to use the environment's protection rules and secrets.
i legit just looked at my own repo's workflows to see what black had
that would then actually require a review before push
that's real nice!
yo what
where is the guide for this
^
I gave up on environments when it didn't work with github pages
it's in beta rn
but I think that's just something specific with pages
to note, i'm pretty sure you don't need that to set up automatic pushes to the other stuff and yada yada
environments are additional layer of security
@errant barn @dense jungle while I have your attention, would it be worth implementing (or discussing) stronger requirements / protections for pushes (direct or merges) to main?
it depends on the project but imo it's not always that great, especially if you want to release a hotfix
and nobody's around
Don't feel a strong need for changes. @solid adder actually likes to push straight to main
as far as I can tell
but generally, it's quite cool, just not for everyone's tastes
I'd like to be able to merge my own PRs without review if I feel it's urgent
I think protecting the PyPI upload might be a good call but in general I don't care about the rest
(if you disagree later we'd be able to revert)
this sounds worrysome
repo admins can overcome the branch protection
^
I don't know if you are one though
well he is one but even his powers are limited due to the repo being under the psf org
they're not limited by much, he can't block people from the repo since that can only be org-wide but pretty much anything concerning the repo can be done by repo's admins
Yeah I think it's a good idea, but I'm not against the current flow since it seems to work. The Encode org (responsible for HTTPX and Starlette and such) has used it to a great effect, since they give write access for essentially all contributors. But here I don't think it's essential
oh and he can't remove the repo :3
π€ You're part of encode?
That surprises me, I'd argue repo specific bans would be useful in enough situations
Well I've put in like one commit but technically yeah :D
lol
Yeah, it's a bit meh, but sadly GitHub only has global blocking
in that case, I would consider myself a part of pypa/pip
aa, i find httpx pretty nice but one thing is very wonky to me lol
cause I made one docs commit
per-org/user
i'm also surprised that starlette still uses requests and not httpx for the test client
I contributed one space to PHP, so I'm part of PHP
But my point was that the branch protection works for them since they have a massive amount of people with write access, but for us not as much
^
you could just require passing status checks
the minimum that branch protection does is just prevent deleting the branch and pushing directly to main
gh blocks you from deleting the default branch right lol
the minimum is preventing force-push
I'd hope so
but repo admins override that anyways
nah you can re-enable that
Yeah I sometimes push to main but not when code changes are involved. But changing docs or tests esp. for some typo or inclusion of a new sentence (or testimonial by zzzeek π) I'd just do in main for convenience.
But if we find that we should protect main then I'm fine with that.
well, then minimum is nothing lol
I mean, admins powers are supposed to be not given out like candy lol
you're a repo admin i assume
Yeah not really dangerous admin powers though π
yes, but I include administrators in the protection
Fun fact, in cpython I have to push the merge to the release branch for the signed tags to remain immutable. So I would untick "include administrators" every release I'm making for a single push.
But our release workflow in Black is much less involved so this problem doesn't really exist here
I have never used code owners
yeah, it's quite granular
turning that off and this off allows pushes to main
I use code owners but not the requirements of the review from code owner
Also, y'all use dark mode for GH? I'm still using the light theme
i use the middle mode
that's the lower contrast one right?
I still have it set to dark in case I decide to open it in mobile browser
and because I can't stop myself from being even more hated, I also use light mode for discord π
I'm wondering how the new high contrast ones will look
/s ofc
now that's a threat π
just don't blind us with screenshots of your discord and we might still become friends one day
:)
believe it or not, I use VSC with the github dark theme
"why you gotta be so damn rude" or how ever that song goes just popped into my head lol
Dontcha know I'm hooman too
but there was always some small thing that annoyed me when I tried to switch and I went back to Sublime
this channel is no longer about black, this is the community within the community
it's the monkeys within the community
Yeah we're going off road and fast :D
since we're not talking about black, here's a cool thing that showed up on GH's roadmap today:
https://github.com/github/roadmap/issues/211
and a few minutes later, some other maintainer steers us back on track
Developers and users of Black are invited to use this channel for discussions on the development and usage of the tool.
Yeah screw that. π
Developers and users of Black are invited to use this channel for discussions.
FTFY
hey, to smoothly develop the tool, we need tools like GitHub!
cooper is waiting on us (me and felix) to declare black ready for a new release and he's gonna come back and discover that we have been -100% productive
or well, text editor :D
fwiw @lament crow, i find sublime better than n++
aaand that's why you shouldn't do ETAs in OSS, takes the fun out of it :)
I'm just waiting on Wu-cash to receive his package
why does that sound like an insult to sublime lol
because i really hate one thing about sublime
this is n++, @bright glacier will love it
I actually used to use N++ when I still used Windows
this is sublime
there is a light mode in sublime
I switch my VSC theme like every two weeks
Saaaame
I'm currently using "Solarized Light"
then buy it
so we have a stalemate here
the biggest change I've done is when I switched from ST3 to ST4 and there was a new color scheme
although I am a big fan of Notis themes too for VSC
Mariana
Kinda reminds me of my audio editor, has my mum's name in the license since she bought it at first π
lolno
that's not that much for 3 years
"hey google, translate 99 freedom dollars into maple surup dollars"
I'm actually disappointed google doesn't answer to that properly
its over 99 iirc
lol i ended up googling this https://www.dailymail.co.uk/news/article-2331770/New-Canadian-100-dollar-bills-reek-like-maple-syrup-national-bank-says-notes-fragrance-free.html
omg I found this awesome wiki article
The Great Canadian Maple Syrup Heist (French: vol de sirop d'Γ©rable du siΓ¨cle, lit.β'maple syrup heist of the century') is the informal name for a months-long theft between 2011 and 2012 of nearly 3,000 tonnes (3,000 long tons; 3,300 short tons) of maple syrup, valued at C$18.7 million from a storage facility in Quebec. The facility was operated...
honestly, Netflix subscription costs more than Sublime if you split Sublime's cost into months :P
anyways its $119.90
i don't have any subs π
well, buy one coffee less per month or sth?
Coffee is bitter.
nope i buy very few things lol
Yes, but why not just use an editor that's free? Unless it has some very nice features like PyCharm Pro.
i mean
if you're happy with your editor then sure
Nagware IIRC
The OpenAI GPT-3 language model has this to say: "99 freedom dollars translated into maple surup dollars is roughly 340 million. That's 2 per second. I'm going to out there and say this
amount will keep increasing, as long as maple keeps getting more popular, and as
long as there's inflation"
Vive le Canada!
pycharm community edition is just free
no nagging
pro is paid, probs with like 30 days trial
GPT is scary sometimes
Pycharm pro is free if you have the right connections π€‘
Sublime Text technically has this clause:
Sublime Text may be downloaded and evaluated for free, however a license must be purchased for continued use. There is currently no enforced time limit for the evaluation.
Name: GitHub Theme
Id: github.github-vscode-theme
Description: GitHub theme for VS Code
Version: 4.1.1
Publisher: GitHub
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=GitHub.github-vscode-theme
or you're maintainer of OSS project :3
ah, you know the same guy that joe knows?
Or if you're a student
Tell that to the users of 7zip
you can convert currency directly here
did you mean winrar
.wa short 100 freedom units to goose
Failed to get response.
LOL
Close enough
and I am an idoit
lol
can't spell lol
HEY, it's called "Canadian goose" not "goose" /s
here i ran it on a bot that returns the errors lol
turns out WolframAlpha servers contain oil - the foreign ministry
@tribal thistle when can sirlancebot allow the command in this channel π₯Ί
it's not necessary honestly
personally lance and @late dew have the worst errors
I honestly donβt even know whatβs filtering it
like, one of them deletes the invoke, the other doesn't
did you forget you have admin / helper / pydis core roles?!
Wdym?
it doesn't allow the partners to use the cmd here but since you are staff it allows you to use them here
I know that much, I donβt know if itβs a whitelist or a perm problem
"Canada is home to overilypolite maple syrup eating bearded axe wielding lumberers who say 'a-boat'"
may be true or not, I cannot confirm or deny
@bright glacier To bring it back on topic once more, I think I'll call it a night. IMO the AST error messages don't have to be in the release since the impact is so small, so feel free to ask Cooper to release.
I've had heaps of fun tonight though :D thanks everyone!
Alright, sounds good. Sleep tight and don't let the bed bugs bite π
I agree with your find on the 3.3-3.5 parsing
Commented on the PR
So much black love going around here
*on
I feel bad for Felix, his review circles are only dull greys, no pretty green or sharp reds :/
are you trying to speed run maintainer? lmao
Any Vim plugin wizards here? We've been considering (re)moving our Black plugin for a while now. It's in poor condition and none of us really works on it. Would love to hear from you! psf/black#2027
echos godlygeek ||using vim for than 15 years iirc||
I guess at that point you would have used a ton of plugins. Personnel I use vim as my lightweight editor (VSCode for anything complex) and I have zero plugins (that might change once I finally upgrade my vim config). It's been like a year and a half of vim so far.
i just use the terminal to run black in vim Β―_(γ)_/Β―
yeah same
@glad pilot π
I know vimscript well. If you're looking for help bringing the plugin into a supportable state, I might be able to help.
Aye, that's great to hear!
For example I think help would be greatly appreciated on the stale vim pull requests π https://github.com/psf/black/pulls?q=is%3Apr+is%3Aopen+label%3A"C%3A+vim"
Sorry, I may have started a bit fast π How familiar are you with Black? (also, I think I've seen your name pop up somewhere)
is this where the smart people talk?
You may know me from here as a mod, or from Black as the guy who complained loudly about Black changing docstrings in a way that changes the AST. Other than that, maybe a mailing list or something π
I'm familiar with Black as a user, but I've never poked into its implementation at all.
I'm moderately shocked to learn that it has a vim plugin - never knew that, and it seems... odd
Oh yeah there was a bunch of discussion about the empty docstring issue and such!
yep, that'd be me. I came on a bit strong, I think, heh
no worries, strong personalities are needed too
Right on, join and you'll become one too ;) let me try that again: So it must be the place for you too ;);)
How so? Should it no be a plugin or :D
the existence of a vim plugin is totally reasonable - I use a neovim plugin that has a mapping for running Black. Maintaining it first party as part of the Black repo seems like an odd choice, though - especially if none of the Black maintainers have much vimscript expertise
Yeah π hence the discussion to drop it
Yes, we're not too happy about it either. Theoretically it has benefits for discoverability but not sure it works well in practice
it seems to not be mentioned by the README.md, so I'm not sure how discoverable it is in practice.
if you decide you want to keep it, I probably can help you work through the open PRs. Nothing stands out to me as too complicated.
Another option we discussed was pulling it out in a dedicated repo or combining with some existing plugins
I'm a bit unclear on how users would even install this plugin. I guess they could point a vim plugin manager at the Black repo - the plugin manager would clone the repo into one of vim's runtime customization directories, and vim would see the autoload/ and plugin/ directories and use them as a vim plugin - and there would just be a vestigial copy of Black that's also there and not used for anything
It's mentioned in https://black.readthedocs.io/en/stable/integrations/editors.html#vim
Plug 'psf/black', { 'branch': 'stable' } - so, yeah, that works the way I just said. They clone an entire copy of the Black repo, and only use 2 files out of that clone π
or maybe 3, if there's a help file I haven't spotted
Well, I dunno - if you guys decide you want to maintain it, I can probably help you maintain it, but I think there's a plenty good argument for not maintaining it and making it the problem of someone with more expertise.
And on the other-other hand, if you do remove it, any vim users who ask their plugin manager to update their plugins will pull down a new version of Black that doesn't include the vim plugin, and it'll just break for them. Which is pretty annoying.
That's a pickle for sure. For now I think that it's worth at least taking care of current contributions. Then we can perhaps start asking around if there would be people interested in taking this on in a longer run and evaluating the options.
I'll try to take a closer look at those PRs tonight
thank you!
nice, pickle
whelp, I'mma probably get a review request for that π
somehow this is crashing mypyc (heavily simplified from src/black/parsing)
import ast
from typing import Any, Union
ast3: Any
from typed_ast import ast3
def stringify_ast(value: Any) -> None:
# this line is the issue, removing it or removing the typed_ast AST types avoids the crash
if isinstance(value, (ast.AST, ast3.AST)):
pass
else:
stripped = [line for line in value.splitlines()]
I get:
β― mypyc test.py
Traceback (most recent call last):
File "mypyc/irbuild/builder.py", line 158, in accept
File "mypy/nodes.py", line 1956, in accept
File "mypyc/irbuild/visitor.py", line 242, in visit_list_comprehension
File "mypyc/irbuild/expression.py", line 651, in transform_list_comprehension
File "mypyc/irbuild/for_helpers.py", line 97, in translate_list_comprehension
File "mypyc/irbuild/for_helpers.py", line 156, in comprehension_helper
File "mypyc/irbuild/for_helpers.py", line 122, in handle_loop
File "mypyc/irbuild/for_helpers.py", line 58, in for_loop_helper
File "mypyc/irbuild/for_helpers.py", line 278, in make_for_loop_generator
File "mypyc/irbuild/builder.py", line 702, in _analyze_iterable_item_type
test.py:14: KeyError: <mypy.nodes.CallExpr object at 0x7f2753e2af20>
If I get rid of the Any type annotation for ast3, mypyc stops crashing ...
https://github.com/psf/black/actions - Off goes PyPI upload etc.
@bright glacier did you already update to the latest release of mypy? it just came out after a long time, so there's a lot of changes
oh yeah I forgot one came like what in this week?
I guess that error would happen if it didn't run type inference for some expressions?
yes
.pre-commit-config.yaml line 22
rev: v0.812```
*no
updating may give you new bugs or new features π
I think that's a no-go for us unfortunately since we use a local hook
Hmm - I wonder if we can PR that. I might look one day.
O seems there is an issue at least
It's marked with a "pro" label so probably out of reach for us.
oh of course I already forgot third-party stubs need to be installed seperately
oops π
you could just always make a workflow running pre-commit autoupdate right
I do have an abandoned script somewhere on my HDD that handles that lol
not really keen on actually using it tho
and yeah no, mypy 0.902 did not fix the KeyError sadly
Probably it thinks the else branch is unreachable and therefore doesn't analyze it
also Quora is now running black 21.6b0 π
oh yeaaa now I'm a traitor again because my local black is outdated
gimme a moment
β― python -m pip install black --upgrade
Requirement already satisfied: black in /opt/python3.8.5/lib/python3.8/site-packages (21.5b2)
Collecting black
Downloading black-21.6b0-py3-none-any.whl (140 kB)
|ββββββββββββββββββββββββββββββββ| 140 kB 206 kB/s
Requirement already satisfied: mypy-extensions>=0.4.3 in /opt/python3.8.5/lib/python3.8/site-packages (from black) (0.4.3)
Requirement already satisfied: toml>=0.10.1 in /opt/python3.8.5/lib/python3.8/site-packages (from black) (0.10.1)
Requirement already satisfied: regex>=2020.1.8 in /opt/python3.8.5/lib/python3.8/site-packages (from black) (2020.7.14)
Requirement already satisfied: appdirs in /opt/python3.8.5/lib/python3.8/site-packages (from black) (1.4.4)
Requirement already satisfied: pathspec<1,>=0.8.1 in /opt/python3.8.5/lib/python3.8/site-packages (from black) (0.8.1)
Requirement already satisfied: click>=7.1.2 in /opt/python3.8.5/lib/python3.8/site-packages (from black) (7.1.2)
Installing collected packages: black
Attempting uninstall: black
Found existing installation: black 21.5b2
Uninstalling black-21.5b2:
Successfully uninstalled black-21.5b2
WARNING: The scripts black, black-primer and blackd are installed in '/opt/python3.8.5/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed black-21.6b0
WARNING: You are using pip version 21.0.1; however, version 21.1.2 is available.
You should consider upgrading via the '/usr/bin/python -m pip install --upgrade pip' command.
totally readable
Your pip much old
fixed as well π
Python 3.8 though?
Ok Quora 3.6 guy π
I do have Python 3.9.5 compiled on my machine I just haven't migrated my main env yet
I'm trying π
hmm, I might have found a simple workaround for the KeyError, I'm hoping that it still works in src/black/parsing.py
yeah I think you're right on the general issue @dense jungle , removing the Any annotation or using this discovered workaround makes mypy yell at me to put back a type ignore (there was originally one in that branch but then using Any, it wasn't needed)
YAY, I fixed it with an actually not too invasive workaround π
diff --git a/src/black/parsing.py b/src/black/parsing.py
index c912348..79808ca 100644
--- a/src/black/parsing.py
+++ b/src/black/parsing.py
@@ -5,6 +5,11 @@ import ast
import sys
from typing import Any, Iterable, Iterator, List, Set, Tuple, Type, Union
+if sys.version_info < (3, 8):
+ from typing_extensions import Final
+else:
+ from typing import Final
+
# lib2to3 fork
from blib2to3.pytree import Node, Leaf
from blib2to3 import pygram, pytree
@@ -134,6 +139,10 @@ def parse_ast(src: str) -> Union[ast.AST, ast3.AST, ast27.AST]:
return ast27.parse(src)
+ast3_AST: Final[Type] = ast3.AST
+ast27_AST: Final[Type] = ast27.AST
+
+
def stringify_ast(
node: Union[ast.AST, ast3.AST, ast27.AST], depth: int = 0
) -> Iterator[str]:
@@ -173,7 +182,7 @@ def stringify_ast(
elif isinstance(item, (ast.AST, ast3.AST, ast27.AST)):
yield from stringify_ast(item, depth + 2)
- elif isinstance(value, (ast.AST, ast3.AST, ast27.AST)):
+ elif isinstance(value, (ast.AST, ast3_AST, ast27_AST)):
yield from stringify_ast(value, depth + 2)
else:
OK, next release we're turning on the improved string handling features, what bugs do we still have to squash first?
Glancing at the issue tracker, I see two:
- https://github.com/psf/black/issues/2313 (experimental string processing crash on very long variable name)
- https://github.com/psf/black/issues/2314 (Performance regression with experimental string processing)
2313 is related to string splitter removing the parent of originally passed line here and never being set back by anything else (so in-place change of something passed by the caller and something else assuming that the parent will exist somewhere else):
https://github.com/psf/black/blob/main/src/black/trans.py#L1038
But that's as far as I went before deciding that it's out of my league for now lol
src/black/trans.py line 1038
insert_str_child = insert_str_child_factory(LL[string_idx])```
GVR is all over the new parser doc β¦
nice!
I'm incredibly confused, could you explain please?
I'm bored while I wait for clang to compile black :p
he added some comments to https://docs.google.com/document/d/1QPqm01E7MIRi_l4jrgCGOFVThP_HINnkm4hmVZC_CSg/edit?fbclid=IwAR03VBxQLhXkrZiO7BDUQerkeQU7MOy51BHtJ9xqRMHonBF7_dF1Tef53fs#
Black blib2to3 to $NEW_PARSER Lib2to3 is deprecated. Therefore, with blib2to3 being built on top of said deprecated library, itβs not going to evolve with new language changes. Due to this, black will need to adopt a new base parsing library. Purpose of this document This document is to describe...
and suggested we write our own π
.pre-commit-config.yaml directs the user to README.md for information about "Version control integrations", but as of #2174 this information is now located at docs/integrations/source_version_control.md.
This commit fixes this broken reference.
I did lol @ that
oh wow lol
I'm thoroughly surprised
It would be relatively easy to adapt the PEG parser generator used by CPython to generate Python instead of C
I mean, that's a valid suggestion
hi :D
Ayy thank you! This is great!
We have money to pay someone to try do the GVR suggestion too β¦
I just read that, nice
althoughveryminordetailitsTBDnotTBA
it stands for "to be ascertained"
no
yes, just kidding
i did add a con of one of them for you π
oh yeah, sounds like that's still open: https://github.com/davidhalter/parso/issues/138
Describe the bug
If concatenating 2 comprehensions, content is indented and surrounded by a pair of parentheses.
To Reproduce
This is an example. The first variable (pre_grid) is assigned the concatenation of two comprehensions, while the second one (gr_grid) concatenates five. The difference in formatting is misleading in this context because both variables have similar semantics. I'm unable to find a good reason why they should be formatted different.
pr...
psf/black#1948 led to Instagram/LibCST#490 which depends on Instagram/LibCST#285
yes I just found that issue too, let me link it to the doc
the benefits of doing all of this mypyc related benchmarking is that I have reasonable decent benchmarking tools, which is great because I had planned to create some a long time ago but never did
FYI: I'm just going to say random stuff as I wait for this benchmarking to finish
@dense jungle you miiiight want to take a look at this open issue
favourite color?
Uhm
yes, that one could cause issues if we end up using libcst
@bright glacier there's only one right answer
Blue and Pink are both great colours
wrong
purple
wrong
black ofc
no!,
and favourite colour with at least one bit flipped on?
told ya already
that looks awesome!
i'm just gonna keep vsc as my discord pfp but colorized it for the seasons lol
anyways, cya
see ya later
oo
I just realized
I have now contributed to the same google document that the founder of python has contributed to
my life has reached its climax, there is nothing higher than this honour.
whelp, initial work on further optimizing black after getting mypyc working ain't so successful π¦
uh
why is this in a foreign language?
send help I can't read the docs of python
was trying to read the ast docs right now to help with the doc above
the universe is trying to convince you to not use Python by removing one of its strengths, its docs /j
imagine if the docs were python's strengths /s
good point, nice knowing ya. Imma go learn rust have fun!
oh fun
I took a stab at 2 of the 3 open C: vim PRs, and commented with patches in lieu of being able to push to the PR branch. The third, I don't much like - https://github.com/psf/black/pull/1319/files is proposing to change the public interface of the plugin, so that the :Black command takes arguments. It wants to take them in a strange format - comma-separated pairs of key=val pairs - which I don't think I've ever seen another vim command take. Vim commands that take arguments usually look more like how CLIs take flags and arguments, and I don't think I've ever seen a vim command take comma-separated arguments instead of space-separated. It's strange.
The approach here is basically a hack, I think - the format they chose for the arguments was chosen so that they could be passed directly to a Python function as kwargs, despite that being a non-idiomatic way to pass arguments to a vim command.
I'm not even sure that I buy the argument that it makes sense to be able to pass arguments to a single call to Black, instead of saving settings into a pyproject.toml file or at least setting the g:black_* variables in your vimrc. The whole point of Black should be that you're running it repeatedly to keep the style consistent over time - I'm not sure I understand why you'd want to make it easy to run with different settings than it has been configured to use.
Thanks a ton! Now we can really make better decisions with them ππΏ
Also, the stable docs seem to be missing the 21.5b2 and the latest release. I suspect this is because of the stable git tag, so it should probably be moved!
hELLO
@keen oasis I'm not so sure this is appropriate here. The rules of PyDis are quite strict about advertising, and this is a channel about a specific project!
@errant barn deleted
Thank you, much appreciated. Though I hope that you find what you were looking for elsewhere!
Add a new line at the end of python file or not to remove it
Currently black removes extra blank line after python code at the end of file.
Tested inside the docker build from the repository.
root@8c79a371a51b:/# black test.py --check --diff --verbose
--- test.py 2021-06-11 09:53:10.665099 +0000
+++ test.py 2021-06-11 09:53:15.809714 +0000
@@ -1,6 +1,5 @@
def main():
print(11)
main()
-
would reformat test.py
Oh no! π₯ π π₯
1 file would be reformatte...
For Python! Have a look at the pinned issues messages mate π
pinned issues mate?
I think you meant pinned messages
Already there mate ;)
It uses and edits a syntax tree to produce new code
it has logic that takes whatever input and turns it into code that follows the "black code style"
ok
it has no true sense of whether code is good or bad it just knows how to take some code and make changes that follow the black code style
so its like pylint but it fixes stuff instead of telling you whats wrong
eexactly!
oh ok
in a way yes, but we don't have error messages and we can't, black is a formatter not linter
black is just about style, pylint is about more
but black is very good at style ;)
basically let the computers worry for code style, not humans
Yeah ichard noticed that. I'll move in tonight/tomorrow if no 21.6b0 issues come in
!remind 1D check on 21.6b0 release status and maybe move stable tag
Sorry, you can't do that here!
ah looking at the code, it seems like staff can make a reminder anywhere while everyone else (including me!) can make in these places:
config-default.yml lines 244 to 246
reminder_whitelist:
- *BOT_CMD
- *DEV_CONTRIB```
Should be a single line change
Would you like to PR this category into that?
I would do it, but not at PC
Would it need an issue for further discussion first?
Cool then, I can PR it later once my time is freed up in an hour and a half
me wishes I could use reminders here so I don't forget to do the PR
i.e. privliiges
!remind 90M 429445826251587616 dew it
lol
such power
!remind 429445826251587616 90M dew it
Your reminder will arrive in 1 hour and 30 minutes and will mention 1 other(s)!
Or I could just fuck it up
Ye
I wouldnβt at a glance either haha
just curious, how do you find that id?
Press/right click on a user and click βcopy IDβ
You may need to enable developer mode first
can confirm this requirement
thanks, that did it
@tribal thistle @bright glacier
Here's your reminder: dew it.
[Jump back to when you created the reminder](#black-formatter message)
very nice reminder mentions
now dew it π
oh since I'm making a bunch of vsc logos
i made one for black
nah this is the real one
the contrast is so bad it's beautiful /s
ugh, the setup required for testing changes for pydis-bot seems to be really involved
We know and have plans to address it, but not enough time to work on that stuff lately.
It's acceptable, I've just gotten used to being really simple to get a dev env quickly for the python projects I work on
If you're just whitelisting this channel, it should only be a config change and could forego testing.
We'll see, I don't trust myself enough to do an one line change and I might need a pydis-bot test env later so I'll try for now and see how much effort it will really take π
Yeah no I do not feel like setting this up, got like half way done and I don't feel like doing this lol
Does show how big this server really is though
Yeah itβs not fun to set up lol
everything except for the channels is acceptable, but my goodness there is a lot of channels
it really is
Anyways, you could add it in without testing, or I could have a look at it in the morning
The good news out of it is that it was my first time using poetry lol
Yeah? How was it π
I had a not so great experience with pipenv (although I still use it for black) so I gave up on that class of tools forever until now
But poetry actually felt polished, I'm not sure if the "handle everything" nature of these tools is something I'll grow to like, but at least I feel like care was taken :p
Poetry actually is less βhandle everythingβ than pipenv
It doesnβt have scripts
Ofc we have a plug-in to do itβ¦
So wait, I just make the oneliner change in /config-default.yml right?
This category is probably not in the constants file, so itβll have to be added in as well
oh fun
That just involves adding the ID to the yaml, and the type (int) to the constants.py
So correct me if I'm wrong, but I need to do:
- get the ID of this category and put in the YAML file
- add the type to constants.py
Yeah thatβs basically it
- and finally add this channel to that other section
Yeah that step is pretty important too lol
OK, not too bad although I'm the guy who would make 10 force pushes for a small change π
I canβt remember if the filter handles categories. If it does, I think it would make sense to add the entire OSS category, if not, we could add just black. I should check lol
Well, the policy allows you to do it π€‘
Is the server template up to date? It didn't exactly look like it
I mean, it sounds like a pain to keep up to date, but I'm curious
So basically, yeah, but, it doesnβt have all the channels. It has all the channels you need to setup and run the bot, but fewer channels than the main server to keep it navigable
hey i like it!
The only things youβd have to add on to the template are one emoji of your choice
Oh we probably drowned this channel
This should probably be documented somewhere lol
Would you like to continue in #dev-contrib?
sometimes 10 commits are made for a small change and then just forcepush or squash merged
Yeah probably
although honestly
this channel gets derailed constantly by me
Lol Iβll take this one
I can get excited inducting a new sacrificial goat to the academy of pydis contributing
!remind 20H check on 21.6b0 ~release~ bugginess status and maybe move stable tag
Your reminder will arrive in 20 hours!
I make that reminder and yet I don't see any new bugs since the release yesterday
just psf/black#2328 which doesn't seem like it should exist, IIRC it was fixed in 20.8b1
Describe the bug
I have this file header in my source that I'd like to not mess with since it's got license information for code that isn't mine. So I wrap it in # fmt: off; ...; # fmt: on to preserve the block, but the block gets formatted anyway (a space gets added after the #).
Before black:
# fmt: off
#===- cindex-dump.py - cindex/Python Source Dump -------------*- python -*--===#
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Excepti...
our reaction time is sometimes nuts
Alright, I got the 2 vim PRs godlygeek suggested patches for updated, they should be ready for review (not sure by who tho) and then merging
Trying to get the open PR count lower to reduce the burden on PR review resources
one of mine I take it as?
its not π
the funny thing is, its old enough that it only had 26 checks
rather than the now 36
and we might get more once I hook up mypyc to black
a compiler for statically typed python code, turns such code into a Python C extension for speed improvements @plain atlas
so black will be a c extension?
Perhaps obvious by the name, it's based off mypy
Yes, but that should be an implementation detail (well there's a few breakage concerns but they should be minor)
The main one is that monkeypatching will break (this does actually break some of our test suite) but expecting that to work (and stay supported) for an application that technically isn't officially a library is IMO a stretch
I spotted a typo.... Or, merge-o? a minor mistake in one of them. The other looks fine, but I made a nitpicky suggestion about the changelog entry.
Hey @gritty marsh please keep messages on topic
Is the lib2to3 parser framework powerful enough to support features from the new PEG parser? CPython docs say lib2to3 is deprecated because it canβt support PEG syntax.
Chiming in late, it depends on the complexity though it is possible (at least as far as my experimentations go). Both parenthesized context managers and soft-keywords can be implemented, though in case of ambiguity it might require a bit more annotations (something like cut in the PEP 617, to commit to a rule). It is kinda harder when you try to do it on a parser with error handling (parso) but for black it should be easier to implement those 'hacks'.
Thank you!
The third vim PR - https://github.com/psf/black/pull/1319 - is a feature request, not a bug report.
Two features, in fact:
- the ability to set the target version for the plugin's call to Black (new vim variable for setting the default, plus ability to read a per project setting from pyproject.toml)
- the ability to override every setting on the vim command line by making the
:Blackcommand take arguments.
If a maintainer decides that the features should be implemented, I can help make a more idiomatic implementation of them, but I'm probably not in a position to be making decisions about the direction of the plugin on my own.
@bright glacier
Here's your reminder: check on 21.6b0 ~release~ bugginess status and maybe move stable tag.
[Jump back to when you created the reminder](#black-formatter message)
ah yes
@neon loom I suggest to move the stable tag, the newline being stripped issue is unreproducible for both me (using the docker steps the OP provided) and Felix (using a normal dev env since he doesn't know docker AFAIK)
Stable tag reminded me of something I wanted to ask. Does the pre-commit hook fail if it detects black needs to format something?
I was avoiding using stable because I figured I need to run it separately, and "stable" is obviously not on pypi
Well, honestly I wouldn't recommend using stable for pre-commit (even though IIRC that's what is in the pre-commit integrations docs)
pre-commit won't track changes to the stable tag
which is IMO a good thing (also git tag ]safety makes that annoying anyway)
But yes, the pre-commit hook should fail if it makes modifications to a file watched by pre-commit
although you can also use the --check flag to make black return a non zero return code if it would make changes (it doesn't actually touch the files tho)
Ah okay I thought it was going to just fix it all and include it in the commit. Now that I think about it, I'm not sure if pre-commit even has the means to do that.
IIRC the pre-commit developer rejected an feature request for automatically adding the changes from a failing hook
Wouldn't it be ideal to use --check in pre-commit always then? It's redundant to actually perform the fixes.
how is it redundant?
I mean in CI
in CI yes
Sorry, important to mention that
it doesn't really matter tho
or rather contributors can
pre-commit and black both have diff options
and speedwise should be mostly the same
Would there be a nice way to integrate that output with GitHub annotations?
Not implemented although accepted: psf/black#1764
Ugh so that's why
Okay, cool. I'll look forward to that then.
I wouldn't hold your breath, our feature development leadtime ain't great, especially since I expect significant discussion for this implementation because that will be the first output format (other than diff) black will support
Why not? You said it won't track changes but then go on to say that's a good thing.
This is why black reformats the code with a hook but doesn't actually save the code ;-;
