#black-formatter

1 messages ยท Page 18 of 1

plain atlas
#

!pypi pytest-cov

late dewBOT
bright glacier
#

and?

plain atlas
#

ยฏ_(ใƒ„)_/ยฏ

#

I just wanted to let you know of it, if you didn't already

late dewBOT
#

requirements/tests-cov.txt line 1

pytest-cov>=2.12.1```
plain atlas
#

lol

bright glacier
#

I started another mini-project so my open source time has been limited

plain atlas
#

awh, you started a closed source project? ๐Ÿ˜”

bright glacier
#

I basically started a new and improved version of black-primer using ideas from mypy-primer

#

which originally took ideas from black-primer

#

so in a way, I'm trying to be even better than mypy-primer

plain atlas
#

lol

bright glacier
plain atlas
#

ah lmfao

#

I have uh

#

2 repos for one project as it stands right now, soon to be 3 or 4 repos lolol

bright glacier
#

the first major improvement is much prettier output (although if I want to be mostly feature compatible with black-primer this may have to go, but hopefully not)

bright glacier
plain atlas
#

its not

#

one repo is the main project

#

but due to the nature of the project, default assets will likely on a seperate repo

#

configurave is a repo too

#

and then there will project extensions in another repo

bright glacier
#

ah, so this is how you were going to rope me into talking about configurave

plain atlas
#

eh

#

tl;dr configurave is basically a helper to be able to define a configuration and have it sourced from .env, terminal environment vars, multiple toml files, and other sources

plain atlas
#

configurave is still in alpha and was written in 30 minutes out of annoyance, or so I was told.

bright glacier
#

I am quite slow when it comes to anything

#

that sort of development speed sounds amazing

plain atlas
#

lol

#

its still extremely buggy and not exactly usable

bright glacier
#

diff-shades is like 513 lines of somewhat maintainable code

#

it's basically the core logic of the file that's sorta of a mess

plain atlas
#

๐Ÿ˜”

#

diff shades sounds cool

bright glacier
#

it's my take on black-primer

#

why shades? shades of black

plain atlas
#

ah

#

lol

#

huh

#

you just taught me something lol

#

i did not realise that http.server could easily just... serve... a directory

bright glacier
#

looking at next-pr-number ?

plain atlas
#

yes

#

i'm now adding an action to my taskipy tasks

#

python -m http.server --directory htmlcov -b 127.0.0.1

bright glacier
#

I just use alias wb "python -m webbrowser"

plain atlas
#

lol

#

reason to have the taskipy tasks is now its for everyone on the project

#

oh

#

I've been meaning to ask

#

how can I make black ignore a folder

#

current config

[tool.black]
line-length = 110
target-version = ['py38']
include = '\.pyi?$'
bright glacier
#

--exclude=/folder/

plain atlas
#

so

#

exclude = ["/folder/"]?

bright glacier
#

no, exclude = "/folder/"

#

it's a regex

plain atlas
#

how to exclude multiple folders, in the toml then?

late dewBOT
#

pyproject.toml lines 12 to 19

extend-exclude = '''
/(
  # The following are specific to Black, you probably don't want those.
  | blib2to3
  | tests/data
  | profiling
)/
'''```
plain atlas
#

i uh, need to read more docs because

#

target-version = ['py36', 'py37', 'py38']

#

I was setting this to the lowest version supported by the project its formatting

bright glacier
#

honestly, I don't know why black needs all of the versions

plain atlas
#

but you work on it

bright glacier
#

there's an issue on the tracker about it, but we semi agreed that making it a lower bound is probably a good idea

plain atlas
#

I thiiink its so it tests its valid ast on all of those interpreters if it can find one??

#

i have no idea

#

that's something that would make sense if that's what it does

bright glacier
#

I'm not 100 sure either

#

3.6 and beyond is pretty much the same

plain atlas
#

:=

bright glacier
#

other than some syntax changes, nothing special

late dewBOT
#

src/black/parsing.py lines 37 to 48

def get_grammars(target_versions: Set[TargetVersion]) -> List[Grammar]:
    if not target_versions:
        # No target_version specified, so try all grammars.
        return [
            # Python 3.7+
            pygram.python_grammar_no_print_statement_no_exec_statement_async_keywords,
            # Python 3.0-3.6
            pygram.python_grammar_no_print_statement_no_exec_statement,
            # Python 2.7 with future print_function import
            pygram.python_grammar_no_print_statement,
            # Python 2.7
            pygram.python_grammar,```
plain atlas
#

seems like its for those

#

so like

#

exec()
print()

bright glacier
#

it's also used for Feature.*

#

so black knows whether it can do a certain thing or not

plain atlas
#

yeah

#

even though its not really supposed to change the ast

bright glacier
#

3.4 and 3.5 introduced trailing comma support for func signatures and calls

plain atlas
#

but sadly does change the ast in a few places

#

like

#

isn't --strict supposed to keep ast identical?

#

or was that added as a result of that conversation

bright glacier
#

we don't have such a flag right now

plain atlas
#

did it at some point?

bright glacier
#

never did

plain atlas
#

uh

#

I need to go open 20 tabs to check which of dev tools I remember strict from

bright glacier
#

other than docstrings, black is safe

#

it's probably mypy

plain atlas
#

i don't use mypy LOL

#
[tool.poetry.dev-dependencies]
black = "^21.7b0"
codecov = "^2.1.11"
coverage = { extras = ["toml"], version = "^5.5" }
flake8 = "~=3.8"
flake8-annotations = "~=2.3"
flake8-bandit = "^2.1.2"
flake8-bugbear = "~=20.1"
flake8-docstrings = "~=1.5"
flake8-isort = "^4.0.0"
flake8-string-format = "~=0.3"
flake8-tidy-imports = "~=4.1"
flake8-todo = "~=0.7"
isort = "^5.9.2"
pep8-naming = "~=0.11"
pre-commit = "~=2.1"
pytest = "^6.2.4"
pytest-asyncio = "^0.15.1"
pytest-cov = "^2.12.1"
pytest-dependency = "^0.5.1"
pytest-docs = "^0.1.0"
pytest-xdist = { version = "^2.3.0", extras = ["psutil"] }
taskipy = "^1.6.0"
bright glacier
#

we added this docstrings handling code that was supposed to handle the case where black is converting 2-space indentation to 4-space incorrectly

#

but it turns out it touches a lot of whitespace within docstrings

plain atlas
#

related: i cannot wait for poetry 1.2.0 to release, for the dependency groups
Can move all 7+ test deps above to a second group

bright glacier
#

yeah, you're not the first person to complain about it

tired shard
bright glacier
#

I personally don't think we should be even touching docstrings (except for maybe the quotes placement) since everything in 'em matter

#

but I don't feel strongly, I don't really make these sort of decisions here

plain atlas
dense jungle
#

@bright glacier I didn't read all of the above but mypy ended up pinning tomli to a version that doesn't have the annoying CR thing, that may make your life easier too with mypyc

flat krakenBOT
stuck vapor
#

woohoo, thanks for the merge!

I've made a PR to address the first TODO you've brought up, but I don't understand the second one.

just document the quirk

Which quirk are you referring to?

stuck vapor
#

For the purpose of documenting the new pre-commit hook, what would be the next version of black? 21.8b0?

red sedge
#

(we can always deal with any remaining issues as they get reported).

Yes!

half hearth
#

I really like the code formatter

sour jay
#

And well, anyone using anything else in terms of styling of doc-strings.

red sedge
sour jay
#

I mean that's true, it's not a styling thing that bothers me as much as other stuff. But it's something I definitely notice and should be enforced by an opinionated doc-string.

red sedge
#

There's something enforcing it in most codebases I'm using. Maybe flake8?

slim olive
#

There's pydocstyle which can be plugged into flake8 with flake8-docstrings

red sedge
#

Yeah I'm pretty sure I'm not using it...

#

I think people are just formatting these by hand

slim olive
#

Yes, pydocstyle only checks the style and complains if it's wrong

#

it doesn't know how to fix it

#

I'm not aware of any commonly used docstring formatters... it probably makes sense that this is something humans should do

spring matrix
#

:lem

plain atlas
#

Hey hey black team, does black load the entirety of the pyproject file or can it just load the part that it needs?

bright glacier
#

That sounds more like a feature of the TOML library we're using, and as far as I know tomli does not support that

austere lava
bright glacier
#

Oooo nice! I wonder how hard that last 1% is going to be ๐Ÿ™‚

#
# HACK: I know this is hacky but the benefit is I don't need to copy and
# paste a bunch of black's argument parsing, file discovery, and
# configuration code. I also get to keep the pretty output since I can
# directly invoke black.format_file_contents :D


def get_project_files_and_mode(
    project: Project, path: Path
) -> Tuple[List[Path], black.FileMode]:
    import black

    files = []
    mode = None

    def shim(sources: List[Path], *args: Any, **kwargs: Any) -> None:
        nonlocal files, mode
        files.extend(sources)
        mode = kwargs["mode"]

    with suppress_output(), patch("black.reformat_many", new=shim):
        black.main([str(path), *project.custom_arguments], standalone_mode=False)

    assert isinstance(mode, black.FileMode)
    return files, mode

One of the more hacky bits of code I've written lately ๐Ÿ˜›

austere lava
plain atlas
flat krakenBOT
#

Sometimes black doesn't add a trailing comma after the last function argument. This happens e.g. when there is a star (*) argument in the argument list.

black_trailing_comma_bug_1.py

def a_function_with_a_star_argument(*, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb):
    pass


def a_function_without_a_star_argument(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb):
    pass
$...
mint barn
#

what is formatter? what the function of it?

late dewBOT
#

dev-requirements.txt line 2

black==20.8b1```
heavy heron
flat krakenBOT
flat krakenBOT
#

error: cannot format schoolroom.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: /tmp/blk_gfkfesa1.log
Oh no! ๐Ÿ’ฅ ๐Ÿ’” ๐Ÿ’ฅ
1 file failed to reformat.

black, version 20.8b1

Mode(target_versions={}, line_length=105, string_normalization=True, experimental_string_processing=False, is_pyi=False)
--- source
+++ first pass
@@ -169,25 +169,29 @@
             {...
rotund cove
#

what is black fromatter

plain atlas
#

!pypi black

late dewBOT
plain atlas
#

@dense jungle what was the bug?

dense jungle
#

I think it was the big magic trailing comma thing that Lukasz eventually fixed by just formatting twice

plain atlas
#

๐Ÿ‘€

bright glacier
#

And this is why I don't run black-primer locally, running black over the whole project selection takes 30+ minutes ๐Ÿ˜ฎ (although this is actually diff-shades in this screenshot)

delicate sky
#

just format correctly to begin with ๐Ÿ˜‰ /s

bright glacier
#

I'm confused, what do you mean by that?

#

It's kinda half the point of diff-shades & black-primer to run on projects that have never interacted with Black so we can catch issues never seen before.

#

Unless the joke is that Black's style isn't good enough?

delicate sky
#

im just joking lol

bright glacier
#

My point was that to me it wasn't the best joke since it wasn't clear ๐Ÿ˜‰

delicate sky
#

ahh, i didn't really look much at what you said
diff-shades meaning it is only doing a dry-run or what does it mean in this case?

bright glacier
#

so diff-shades / black-primer (the latter is the current utility in use, although I wrote the former to be an much improved version) basically takes a list of open source projects, clones them, runs black over them recording the results

delicate sky
#

ahh interesting

bright glacier
#

we use it to compare differences in behaviour between versions of black, check how big the impact of something will be, etc.

delicate sky
#

is there a black command to see if running black would cause any changes
potentially want to add this as part of a CI/CD pipeline to make sure that black was run for the whole project

#

ahh nvm i see --check

swift warren
#

-c key, I believe

delicate sky
#

yeah, thanks

plain atlas
bright glacier
dense jungle
bright glacier
#

black-primer is much better suited at gauging the impact of black on projects in general while diff-shades aims to better gauge the differences between two versions of black. The former is helpful to us too but it's not as helpful. Especially since that sort of data is more for when you're (considering) adopting Black BUT not when you're a developer of Black.

nimble gull
#

how can I tell black I would like no line length limit?

#

tried black -l 0 and black -l -1

errant barn
#

But on a more serious note, I don't think that's an option we want to provide to users. Where would that be beneficial?

lament crow
#

if there is no line length limit, what's even there to style, quotes? :)

#

if someone dared to use multiple lines for something, black would just join it back together in a single line lol

#

I suggest no magic trailing comma handling for the full hands-on experience of lines with no limits /s

nimble gull
#

Why not just interpret -l 0 as no length enforcement?

errant barn
#

Fair enough! Can't argue with preference, but I think the overwhelming majority of people would prefer a reasonable line length limit and wrapping lines longer than that. -l -1 or such could encourage using it, and since Black is opinionated, I don't think we should do that. Does that make sense? Out of curiosity, do you prefer no wrapping in every scenario (list items, strings, long nested collections or calls), or a specific one?

nimble gull
#

I generally think not wrapping makes my code more readable and easier to understand how the program flows. I really like being in control of the wrapping by placing , at the end of the thing and I do that in the cases when I think each element on its own line makes understanding easier.

errant barn
#

I can definitely see your point, but I'm afraid you're swimming against the current because we try to not take previous formatting into account ๐Ÿ˜…

nimble gull
#

I mostly place the a , at the end for function calls where I set a bunch of kwargs

#

oh well, not the end of the world to have some nines together in my pyproject.toml!

errant barn
#

Black is not for everyone, especially if you like to be the one in control :D

errant barn
nimble gull
#

haha! too late!

#

why not remove the line limit config?

errant barn
#

What do you mean?

nimble gull
nimble gull
# errant barn What do you mean?

I was just saying if you think people shouldn't do

[tool.black]
line-length = 999999

Then maybe limit the allowable max line length limit or remove the line-length option all together! I mean Henry Ford only offered one shade of black, right? ๐Ÿ˜‰

#

Or rename the tool to "black (with a configurable opacity)" ๐Ÿ˜„

errant barn
nimble gull
#

I love the concept of the tool and I'm sick of wading through diffs, so I'm thinking today that the loss of control is worth it!

errant barn
#

That's a realisation I've come to as well ๐Ÿ˜„

#

We are waiting with open arms in the "no formatting worries" land for you

nimble gull
#

\o/

#

One other black question I have: is it a bug if black doesn't enforce the configured line length limit?

#

Like, should it break up long strings?

errant barn
#

Pass in --experimental-string-processing and it will! It's being developed.

nimble gull
#

ah cool

dense jungle
flat krakenBOT
bright glacier
#

whelp.

plain atlas
bright glacier
#

yeah, was trying to look at a pypa/pip PR and it 500ed twice, looks pretty crashed to me

#

oh wow, all of the services are yellow

#

๐Ÿ‘€

#

IIRC it wasn't actually super clear whether pip would do this, there was an issue where automated code formatters were being debated. I'm impressed and surprised there isn't as much pushback.

#

Is it just me or do we all feel a bit more responsible for not messing up black's style now ๐Ÿ˜…

#

Oh well, I'm sure we'll be informed very thoroughly if we get it wrong :p

sour jay
bright glacier
#
โฏ pyperf compare_to fmt-fast-clang.json fmt-fast-gcc-10.json -G
Slower (15):
- fmt-fast-flit/sdist: 84.6 ms +- 5.2 ms -> 95.8 ms +- 7.4 ms: 1.13x slower
- fmt-fast-black/output: 38.4 ms +- 2.7 ms -> 43.1 ms +- 3.8 ms: 1.12x slower
- fmt-fast-black/__init__: 409 ms +- 22 ms -> 453 ms +- 31 ms: 1.11x slower
- fmt-fast-black/lines: 283 ms +- 17 ms -> 313 ms +- 21 ms: 1.10x slower
- fmt-fast-comments: 37.5 ms +- 1.9 ms -> 41.3 ms +- 3.1 ms: 1.10x slower
- fmt-fast-nested: 27.5 ms +- 1.6 ms -> 30.3 ms +- 2.9 ms: 1.10x slower
- fmt-fast-black/linegen: 397 ms +- 24 ms -> 431 ms +- 35 ms: 1.08x slower
- fmt-fast-black/mode: 41.9 ms +- 2.6 ms -> 45.3 ms +- 3.6 ms: 1.08x slower
- fmt-fast-dict-literal: 55.2 ms +- 2.8 ms -> 59.3 ms +- 4.8 ms: 1.07x slower
- fmt-fast-black/strings: 72.5 ms +- 3.7 ms -> 77.5 ms +- 6.2 ms: 1.07x slower
- fmt-fast-flit/install: 182 ms +- 12 ms -> 194 ms +- 16 ms: 1.07x slower
- fmt-fast-list-literal: 33.2 ms +- 1.6 ms -> 35.4 ms +- 3.0 ms: 1.07x slower
- fmt-fast-flit_core/config: 285 ms +- 16 ms -> 304 ms +- 25 ms: 1.07x slower
- fmt-fast-black/nodes: 329 ms +- 16 ms -> 347 ms +- 29 ms: 1.06x slower
- fmt-fast-black/brackets: 120 ms +- 7 ms -> 125 ms +- 11 ms: 1.05x slower

Benchmark hidden because not significant (2): fmt-fast-black/comments, fmt-fast-strings-list

Geometric mean: 1.08x slower
#

So gcc takes longer to compile while using twice as much memory to do so, produces binaries that are basically no smaller than clang's, is more picky about the C code it's given, and finally is slower ... what was I thinking gcc was viable :>

#

Anyway it seemed like the last set of optimizations have netted me a ~3-6% additional perf win which is nice! Especially since I got lazy and didn't do as much analysis for this optimization pass ๐Ÿ˜›

plain atlas
#

hello ichard

bright glacier
#

hey arl

plain atlas
#

is blackbench or diff-shades useful for a end user of black?

bright glacier
#

I mean you could use diff-shades to see the impact of a different revision of black but like it would be easier to just run black with the diff flag

#

And blackbench is purely focused on benchmarking black's performance, not quite sure how that would be useful to an end user

plain atlas
#

ah

#

lol

bright glacier
#

Maybe I'll publish it but maybe not (probably not)

plain atlas
#

apparently can't use it

bright glacier
#

It's in the black-mypyc-wheels project

plain atlas
#

ah

#

contemplating using mypy on my project

#

like

#

it caught a few incorrect typings the other day when I tried it for fun

plain atlas
#

hmmmmmm

#

how does black bump its version?

torn night
#

Hey, working on a project to automate some of my stuff at my job. Do i need to make a channel under open-source projects?

bright glacier
plain atlas
#

ah

silent apex
flat krakenBOT
#

Describe the bug

black does not add the two newlines between these two definitions when there's a comment in the way

a = 1
# adsf
def bar() -> None:
    ...

this causes the following error in flake8:

E302 expected 2 blank lines, found 0

Expected behavior

a = 1


# adsf
def bar() -> None:
    ...

Environment (please complete the following information):

  • Version: 21.7b0
  • OS and Python version: macos 11.4, python 3.10.0...
flat krakenBOT
#

Describe the bug

Dear black developers,

First of all, thank you for this wonderful package!
I wanted to skip one line using # fmt: skip. Unfortunately for my case this "skip"-statement seems to be "ignored" by black. I think the following example to reproduce makes it more clear.

To Reproduce

Consider the following code:

def somefunction(clusters):
    return bool(x)


if __name__ == "__main__":

    class A:
        foooooobaaar = "foobar"

     ...
neon loom
#

@bright glacier Hey mate - Long time, I've been busy with travelling and life for a change so haven't been around

#

Did you ever do any benchmarking with black using uvloop and not using uvloop. Especially blackd - I'd expect maybe less memory usage and maybe lower latency on a busier blackd server more so than a reduction - e.g. 5 files vs. 1 being formatted together (if it can even do that - Never used it directly - Pretty sure my vscode does tho)

bright glacier
neon loom
#

That's all @austere lava's doing tho (He does that for FB or has helped with it)

neon loom
#

*went

bright glacier
plain atlas
#

uvloop is somewhat buggier, i've heard

#

!pypi uvloop

late dewBOT
bright glacier
#

I've never really used it so I have no feel for that, bandersnatch uses it tho and we haven't had any major fires

neon loom
#

@plain atlas I've used it with great success on big busy python services @ Facebook (I work there)

#

And other open source projects

#

As ichard alluded to

plain atlas
#

ah

neon loom
#

I've just not seen if it's a win or not for Black

plain atlas
#

I mean

neon loom
#

I've seen memory 1/2 and latency drop on some services @ FB using it

plain atlas
#

pls be an optional dependency for black, if considered at all

dense jungle
#

I'd guess it doesn't matter as much since Black doesn't interact with the event loop all that much

neon loom
#

It is

dense jungle
#

But worth trying

neon loom
#

Already

bright glacier
plain atlas
#

ah

neon loom
plain atlas
#

i mean, black takes like 0.64s for me so Ig having the uvloop dependency isn't worth it lolol

#

hm......

#

I think I just found a bug.

bright glacier
#

Well OK I thought it was clear drones would be a no-go at a wedding haha

plain atlas
#

black just formatted a file I have gitignored
From docs, and previous experience, I don't think its supposed to do this

bright glacier
#

it's probably mostly the import time being costly

neon loom
#

The photographer had his own to get the shots outside the ceremony

neon loom
#

@bright glacier All the drone footage is shared on my Facebook of course ๐Ÿ˜›

bright glacier
#

Haven't heard of many weddings due to COVID, so it's nice to hear at least one happened ๐Ÿ™‚

neon loom
#

I keep complaining to my friends in the video team about how the downsample my 4k video to crappy 1080p. ๐Ÿ˜ฆ

#

*they

#

They live in the 80s

bright glacier
neon loom
#

I have an internal task to my mate in the team "Give Cooper 4k"

dense jungle
bright glacier
#

Haha, downsampled 4k is probably better than native 1080p so it could've been worse

#

is 1080p really the 80s these days? /hj

dense jungle
plain atlas
#

its a nested .gitignore file

neon loom
#

(Even tho 99% of what I watch is 1080p) ๐Ÿ˜›

plain atlas
bright glacier
bright glacier
neon loom
bright glacier
#

The delta strain is really unfortunate, we're probably on our fourth wave at this point :/

plain atlas
#

well i have a different git problem right now so I'll try and fix that and get back to you

#

also I just deleted those untracked files, FML

bright glacier
#

I did once a week ago and my goodness you don't know how happy I was I had a backup

dense jungle
plain atlas
bright glacier
#

fun.

dense jungle
#

And apparently Australia just doesn't let anyone in?

plain atlas
#

thankfully i copied it from a previous project and it took minor changes

#

and their point was to demonstrate how easy it was to convert other project stuff to this project lolol

#

so its easy to get back, but annoying

#

do any of you use visual studio code?

dense jungle
plain atlas
#

my vscode isn't set as the default editor for cli actions

bright glacier
#

Even if travel is allowed, I fear delta will spread even among the vaccinated folks which would be not great

neon loom
plain atlas
#

and I need to figure out how to set it as said default editor again

neon loom
#

I live in vscode

bright glacier
#

I switched to Vim a long time ago ๐Ÿ˜›

plain atlas
#

my setup is a device over ssh

#

the problem is its using vim instead of vscode for all terminal editing actions

#

specifically git

#

and github's cli too

#

$EDITOR is not set to anything

bright glacier
#

I remember setting up a git config in my vscode user settings that sets vscode as the git editor

plain atlas
#

fun thing is editor runs nano, and not vim

neon loom
#

I have vim plugin on vscode and still live in vim

#

I'm an old Linux BOFH

#

UNIX even - use to run solaris etc.

#

I was upset but understand when fedora changed editor default to nano ๐Ÿ˜ฆ

bright glacier
#
    "terminal.integrated.env.linux": {
        "GIT_EDITOR": "code --wait",
        // this exists so the starship prompt isn't enabled which is broken in VSCODE
        "IN_VSCODE": "indeed!"
    },

that's my solution to using vscode with git relatively painfree

plain atlas
#

thanks

#

hm

plain atlas
#

how can i test the git editor is correct now?

lament crow
#

why?

#

or maybe I should backread fully first

bright glacier
#

I don't remember at all lemme find the issue

plain atlas
#

(basically whats a command that makes git open something to edit without going in to any mode)

#

eh

silent apex
lament crow
#

Now that I did backread, I can be more confident it hasn't been answered ๐Ÿ˜„

plain atlas
#

just make a random edit, commit it, then reset head~1

bright glacier
dense jungle
#

Oh yes, the "gitignore everything" use case, never would have thought of that ๐Ÿ™‚

lament crow
#

hmm

#

does this affect usage of extend/force exclude as well

plain atlas
#

that's an interesting use of gitignore lol

bright glacier
#

extend-exclude still works and force-exclude probably still works

#

the same*

lament crow
#

ah, then I don't really care

plain atlas
#

just a comment on it: I often look at a gitignore file to see what configuration files the project uses

lament crow
#

personally I'm interested in using existing gitignore but I also want to exclude vendored stubs from black

bright glacier
#

TL;DR:

Changes behavior of how .gitignore is handled. With this change, the rules in .gitignore are only used as a fallback if no exclusion rule is explicitly passed on the command line or in pyproject.toml. Previously they were used regardless if explicit exclusion rules were specified, preventing any overriding of .gitignore rules.

Those that depend only on .gitignore for their exclusion rules will not be affected. Those that use both .gitignore and exclude will find that exclude will act more like actually specifying exclude and not just another extra-excludes. If the previous behavior was desired, they should move their rules from exclude to extra-excludes.

lament crow
#

awesome!

plain atlas
#

IMHO to not have a breaking change, USE_GITIGNORE would've been nice lol

bright glacier
plain atlas
#

not until its reviewed ๐Ÿ‘€

bright glacier
#

oh, well that doesn't bode well

neon loom
austere lava
#

Half of that is probably python startup time ๐Ÿ˜Ž

neon loom
#

Are those numbers published anywhere? Otherwise I'm gonna Bug report that Python in residence engineer ..

bright glacier
#

or whatever the benchmarking website URL is

neon loom
#

that's the one

dense jungle
#

Guido's faster cpython project has been working specifically on startup time

neon loom
#

I can't remember too

dense jungle
#

He's been trying to speed up pyc loading

austere lava
#

Nice

neon loom
#

That will be H U G E

austere lava
#

I wish Instagram would/could upstream its runtime improvements

bright glacier
#

And I'm working on better black performance heh (I know, 100% less cool)

bright glacier
neon loom
austere lava
#

Oh that we're working on

#

Stay tuned

bright glacier
#

๐Ÿ‘€

neon loom
#

Make my CLIs great again

austere lava
#

Eggsactly

neon loom
#

@solid adder You got any time for black anymore? Any love for us? ๐Ÿ˜›

bright glacier
#

I've found the DIR weekly reports fascinating. Oh and I'm particularly excited about the issue and PR stats that are apparently coming next week ๐Ÿ˜„

austere lava
#

Where can I read them?

#

I've just seen my 2.5 year old PRs get merged

neon loom
#

Yeah they have been good

bright glacier
neon loom
bright glacier
#

I saw some changes get merged into lib2to3 a few days ago lol

#

I wouldn't be surprised if zsol already implemented the changes (or the functionality of the changes) in blib2to3 a long time ago :p

dense jungle
#

Yes, Lukasz's work has been great, I've been seeing a ton of old PRs getting merged

austere lava
bright glacier
#

Nice! That reminds me that we still need to address the "new parser" issue don't we lol sigh

austere lava
neon loom
#

Shame we have to move out of blib2to3 one day ...

#

*off of

austere lava
#

Yeah so about that

#

I've a few people helping me with the rewrite by now, but am gonna go on vacation end of next week

#

So not sure how much progress there's going to be

dense jungle
#

Your rewrite is for LibCST's parser, right? Or are you also working directly on Black?

bright glacier
#

CPython really gets a lot of PR traffic doesn't it, I would've expected a more noticeable dip from ลukasz's help but nope!

austere lava
#

Nono just libcst

dense jungle
#

So we'd still have to totally rewrite black to work on top of LibCST ๐Ÿ™‚

bright glacier
#

how's using rust with python? or have you not reached that stage yet?

austere lava
#

I probably won't have the bandwidth to do that yeah

bright glacier
#

I ask that because someone just said they made a blackd client in rust lol

austere lava
#

But more than happy to dedicate time to support someone who wants to do it ๐Ÿ˜Ž

neon loom
#

We still have some money and if libcst seems best we can tender out spending that money on getting it done or ask for donations etc.

bright glacier
austere lava
neon loom
#

A client in rust would work ...

dense jungle
neon loom
#

I missed client in the original message from richard and thought someone said they'd make blackd in rust ...

#

Sure - as long as they add CI and documentation ...

#

building, unittests + integration testing with blackd

austere lava
frozen badge
#

too bad, it seems really neat for whenever im gonna try to turn on format on save

bright glacier
#

I'm a bit worried with how we could integrate it with our build system but apparently PyO3 has a setuptools plugin as I've heard?

#

The argument we shouldn't distribute native binaries is already out of the window due to my mypyc work tho

#

unless we decide not to, but I hope not ๐Ÿ˜…

flat krakenBOT
#

Is your feature request related to a problem? Please describe.

I am using the VisualStudio Code extension Better Comments, which works by coloring comments based on a specific symbol/string right after the comment start. The frustrating part is that Black always adds a space in between, which would turn this:

a = 10  #? Should we change this

into this:

a = 10  # ? Should we change th...
plain atlas
#

that was close

#

imagine running black / and not black .

#

temptation got to the best of me

#

turns out what happens is it ||runs in to a .gitignore file it doesn't have permission to read and fatally errors before it does anything||

bright glacier
plain atlas
#

yeah, might be worth it

#

at the risk of looking like i reformatted all of the pythons on my machine at one point, I'll make an issue on the repo

#

psf/black#1

plain atlas
#

^ ignore, just a short link to get my browser open

flat krakenBOT
plain atlas
#

got sidetracked, sorry

flat krakenBOT
bright glacier
#

Made from a phone ๐Ÿ˜„

plain atlas
#

nice

#

i'm curious, do you wait for checks to complete and then merge, or do you need someone else to approve it too?

#

LOL

bright glacier
plain atlas
#

you don't have automerge enabled?

bright glacier
#

larger changes usually have two reviews but one review is enough for those sort of changes

bright glacier
plain atlas
#

that allows you to turn on automerge and then once all checks pass the branch will be merged :)

plain atlas
#

hi

bright glacier
#

salut

plain atlas
#

mrw having problems with windows so I close explorer.exe

#

:)

warped hearth
lament crow
#

why would CamelCase be an error?

plain atlas
#

holy shit lol

#

okay wow

#

I have to share this project here, its very impressive

#

formats all markdown files

#

now, the reason to share it here, is that it has a plugin system, and there is a plugin for formatting python code within the markdown file

#

!pypi mdformat-black

late dewBOT
plain atlas
#

Now I can format all of the code blocks in my markdown files with black as well!

lament crow
#

have you heard of blacken-docs for reStructuredText?

plain atlas
#

no....

#

lol

little parrot
#

It works with md jackenmen

#

I use it

plain atlas
#

!pypi blacken-docs

late dewBOT
lament crow
#

I don't, thought it's just rst

#

but ye, looks like it's rst, md, and tex

plain atlas
#

hmmm

#

well then

#

still would use mdformat for formatting md

#

!pypi mdformat

late dewBOT
lament crow
#

yeah, makes sense for auto formatting of whole markdown files

plain atlas
#

yeah

lament crow
#

I know that when it comes to reStructuredText, there's rstfmt but it's in a very, very early stage

plain atlas
#

not sure that using blacken-docs is worth it if I'm already using mdformat

#

except for one thing

#

mdformat-black requires the code block to be labeled with python

#

pydoesn't count

lament crow
#

seems like a bug

plain atlas
#

yeah

little parrot
#

You can just use both

warped hearth
#

I'd expect it to be identified

plain atlas
dense jungle
plain atlas
#

also uh, dynamic getattr

warped hearth
dense jungle
#

yes, there's lots of ways it's unsafe

plain atlas
#

yeah

#

and it heavily changes the ast of the file

warped hearth
#

imo snake_case is rubbish but that's the way python specs were written. Seems it's often just ignored.

plain atlas
#

i mean, how pep8 was written but yeah

warped hearth
#

has it formally changed since pep8?

dense jungle
#

PEP 8 is just the style guide for the standard library. You can do whatever you want in your own code

#

If it was feasible, Black would enforce snake_case, but it's not feasible so we don't

plain atlas
#

and even more so, the logging class exists

dense jungle
#

yes, even in the stdlib there is lots of legacy code that doesn't follow the conventions

warped hearth
#

Which is crap when you start mixing code from different sources, the whole point of a style guide.

plain atlas
#

logging.basicConfig smh

warped hearth
#

legacy code is a different issue

little parrot
#

All the names for logging I thought were copied from Java

plain atlas
#

yeah

warped hearth
#

In which case you wouldn't expect them to change

little parrot
#

I feel like they could be changed though they did it with the threading module

plain atlas
#

TBH

#

blacken-docs looks a lot better than mdformat-black so yeah

#

ah yes

#

gotta update it all

late dewBOT
#

@bright glacier

It has arrived!

Here's your reminder: maybe, just maybe ask about configurave
[Jump back to when you created the reminder](#black-formatter message)

plain atlas
#

not sure I summarized it yet but tl;dr take inputs from env, toml, default toml, and put it into models so it can be used.

flat krakenBOT
plain atlas
#

i

#

did i

#

noooooooo

#

I misspelled unnecessary.

#

wow

#

@bright glacier I regret my life.

flat krakenBOT
bright glacier
plain atlas
#

force pushes tho

bright glacier
#

not an option on a repo like psf/black

plain atlas
#

i mean, you can on pull requests

#

but yeah, once something gets to main its too late.

bright glacier
#
$ black -c "print("
print(
error: cannot format <string>: ('EOF in multi-line statement', (2, 0))

Haha, I found a unrelated regression while reviewing a PR. Looks simple enough to fix.

#

The input should definitely be not printed if an error occurs :)

plain atlas
#

I guess with an EOF its worth not printing

#

but other errors some of it should?

bright glacier
#

Why should it give back the user what it gave quite explicitly?

#

It's unnecessary and noisy if there's an error blocking black from doing its thing.

bright glacier
#

I haven't closed an issue in a long time haha, feels good to know I'm still reasonably decent at finding duplicates ๐Ÿ˜„

flat krakenBOT
flat krakenBOT
#

Describe the bug

Black failed to format a valid python file. Appears to be something to do with inline comments on a multi-line statement.

To Reproduce

Diff is below:

--- source
+++ first pass
@@ -118,14 +118,14 @@
 
 
 def _get_rates(product: market_supply_models.Product) -> List[GasRateRow]:
     # Gas rates have stepped consumption and one standing charges for each zone identifier.
     rates_rows: Dict[Tuple, GasRateRow] = dict()
-    for rate in (
-     ...
stuck vapor
#

What's the best way of getting the latest released version of black from within the codebase? (this is for the issue of keeping the pre-commit example's rev in sync with the latest version of black)

One way would be to parse it from the CHANGES.md file, but that feels brittle.
I considered using black.__version__ but that gives e.g. 21.7b1.dev9+gb1d0601.d20210810, rather than the latest released version.
Finally, I considered looking at the latest git tag, but figured that that might not fit in with the release process - if a tag triggers a release, then the check to ensure that the rev in the pre-commit example from the docs is synced with the latest release of black would be triggered too late.

frozen badge
stuck vapor
bright glacier
#

are emojis still not acceptable for a command line tool in certain environments?

bright glacier
austere lava
stuck vapor
austere lava
#

I mean you can always use the github api to get the latest release

#

Or something like that

stuck vapor
#

Thanks @austere lava - I tried

        latest_tag = subprocess.run(
            shlex.split(
                "curl -sSL api.github.com/repos/psf/black/releases/latest "
                '| grep \'"tag_name":\' | sed -E \'s/.*"([^"]+)".*/\1/\''
            ),
            universal_newlines=True,
            stdout=subprocess.PIPE,
        ).stdout.rstrip()

but then in CI get

fatal: No names found, cannot describe anything.
curl: (58) could not load PEM client certificate, OpenSSL error error:02001002:system library:fopen:No such file or directory, (no key found, wrong pass phrase, or wrong file format?)

Not sure what this is but I'll investigate

heavy heron
bright glacier
#

I meant this ๐Ÿ™ƒ

dense jungle
#

so you meant acceptable socially, not acceptable technically?

bright glacier
#

yep!

#

like I get they can look out of place, but it feels a bit silly to add a toggle to disable them

#

I'm surprised at how much traffic we've gotten over this tho

stuck vapor
flat krakenBOT
austere lava
#

If I'm fired tomorrow, then we've learned it's better to ask for permission and not forgiveness

delicate sky
austere lava
bright glacier
#

not surprised :p

heavy heron
drowsy sonnet
#

Hello hello. I'm here to be disruptive again: anyone tried Furo with black's documentation yet? ๐Ÿ™ƒ

dense jungle
drowsy sonnet
#

Aye. Nice!

#

Lemme know if y'all see anything disruptive/concerning with Furo.

Most of my Discord channels are muted, but @-mentioning me in this channel (or on the PyPA discord) will reach me.

lament crow
#

I've seen furo has recently been added as an example theme to sphinx's tutorial so that's nice

lament crow
#

In case someone does not follow Pradyun or just doesn't use Twitter

delicate sky
austere lava
#

so far so good ๐Ÿ˜›

bright glacier
#

@dense jungle is there an issue on the mypy issue tracker about renaming the default branch to main or something else? I'm asking rather selfishly because mypy is the only repository I've regularly been developing for that stills uses master but my muscle memory has already learned main so mypy using master is annoying :p

#

I tried looking but tbh the 1700+ issues were impossible to dig through :/

dense jungle
mint barn
#

@bot.command()
async def avatar(ctx, *, avamember : discord.Member=None):
userAvatarUrl = avamember.avatar_url
await ctx.send(userAvatarUrl)

tribal thistle
mint barn
#

was

#

german pls

tribal thistle
# mint barn german pls

This whole server uses English, please see #rules. If you canโ€™t speak English, itโ€™s fine to use something like Google Translate

quartz flicker
#

hey how's it going, I'm trying to use black on python 3.9.6, for some reason it won't work without the --fast param.
receiving errors when integrating with vim/nvim plugins (Neoformat/Formatter.nvim) as well.

bright glacier
#

What's the error you're getting without the flag @quartz flicker ?

#

It shouldn't be crashing due to the integration, I suspect black is buggy on a particular input or your input isn't actual valid python code.

#

In other news, I just finished the last set of changes I wanted before releasing blackbench 21.8a1. This release is special since it's the first one that's going to be published to PyPI. It also will be my first project on PyPI. I don't know if I should be worried or scared, but I am :p

#

CI is green so I guess it's time to try out my release automation and hope nothing breaks. Afterall, what's the worst that could happen?

#

Oh wait, step one is first remembering my PyPI password lol, it's been too long since I've last signed in ๐Ÿ˜…

#
nox > git commit -m Let's get back to development
nox > Alright, just do a push to GitHub and everything should be done
nox > If you're paranoid, go ahead, verify that things are fine
nox > If not, sit back and relax, you just did a release ๐ŸŽ‰
nox > Session do-release was successful.

ahhhhhhhhhhhhhhhhhhhhhhh my blood pressure is still very high right now but I'm excited!

tribal thistle
#

This is what test.pypi is for haha

#

Grats tho!

bright glacier
#

everything actually does seem to be fine ๐Ÿ˜„

#

!pypi blackbench

late dewBOT
bright glacier
#

Hmm, does readthedocs not create a stable version automatically for you if there's only prereleases

#

I guess I'll just make a stable branch for the time being then.

#

Alright, time to benchmark a lot so I can open a PR for my mypyc work soon, but first a break ๐Ÿ˜„

plain atlas
#

yay

plain atlas
bright glacier
#

well the versions won't be freed, once used they are done forever

plain atlas
#

yeah ;-;

#

even though it promises its a test pypi

#

its not actually a "test"

#

its a second index lol

bright glacier
#

that's meant for testing, so in a way, it serves its purpose, not well tho IMO

plain atlas
#

yeah

#

i agree its not well

#

also poetry is buggy rn

#

and I actually don't have a keychain on my device so I have to delete poetry's config every time since it stores creds in a plaintext file lol

#

may see about using twine for publishing instead of poetry NGL

tribal thistle
#

If youโ€™re really concerned about messing up the test index, spin up your own copy

bright glacier
#

Eh, I'm just happy I've done a release on PyPI. I'll deal with security later ๐Ÿ˜‰

#

(disclaimer: I'm not liable for any damages that may occur if you follow my "advice", this is not intended as advice)

tribal thistle
#

Untrue, and OT ๐Ÿคก

lament crow
exotic flume
#

like keepass...

stuck vapor
#

Sorry to bump this again ๐Ÿ˜ณ - is anything blocking the release?

neon loom
#

My time and people telling me of weโ€™re ready or not. GitHub installs always work too โ€ฆ

#

I have some time today - where we at?

dense jungle
#

we should be good for a release. I won't have much time to help out though, we're moving tomorrow and I live in a labyrinth of boxes

neon loom
#

haha - That's fine. I'll take a look later. LinkedIn just suckered me into doing a quiz to get a badge - lol

short forge
#

Congratulations! ๐Ÿ‘

neon loom
#

lol - thanks. Was like, I hope I can pass this.

gusty grail
#

yeah... I think you passed ๐Ÿ˜„

bright glacier
silent void
#

what is mypyc in the context you used the word

bright glacier
#

a Python-to-C transcompiler

silent void
#

that's the cool thing I've heard

little parrot
#

mypyc is a python to c transpiler that uses mypy to make sure what youre writing is "safe"

bright glacier
#

It also uses the type information to optimize in ways that would be unsafe if the type is unknown at runtime.

#

Unfortunately mypyc is still alpha software so extensive testing is necessary before deploying it to PyPI, right now I'm doing one of those testing runs

#

Ah crap, looks like blackbench is buggy with mypyc compiled Black

#

cool, so mypy didn't catch this bug because one of my type annotations were wrong (should've been Optional[str] not str) and I doubt mypy could ever hope to catch this type annotation issue due to how the function is called.

little parrot
#

do you use --strict?

neon loom
#

I think we should do a release with what we have and do a dedicated no changes for mypyc so we can see if we get any "mypyc" related new bugs etc.

bright glacier
bright glacier
#

Although I expect other classes of bugs and edge cases

neon loom
#

Sweet

bright glacier
#
โฏ python ../black-mypyc-wheels/diff_shades.py compare main-e465acf.json linux-mypyc-e9834e0.json 
Loading files ... done

aioexabgp (19 files): everything is the same
attrs (46 files): everything is the same
bandersnatch (50 files): everything is the same
blackbench (13 files): everything is the same
channel (44 files): everything is the same
django (2692 files): everything is the same
flake8-bugbear (27 files): everything is the same
hypothesis (384 files): everything is the same
pandas (1390 files): everything is the same
pillow (275 files): everything is the same
poetry (310 files): everything is the same
pyanalyze (48 files): everything is the same
pyramid (178 files): everything is the same
ptr (5 files): everything is the same
pytest (248 files): everything is the same
scikit-lego (124 files): everything is the same
sqlalchemy (590 files): everything is the same
tox (94 files): everything is the same
typeshed (2306 files): everything is the same
virtualenv (145 files): everything is the same
warehouse (504 files): everything is the same

As usual, we're done here, have a wonderful day/night! Cya! <3
neon loom
#

Yeah, I have - experience with all this but it sounds cool

bright glacier
#

I may have made a better version of black-primer ๐Ÿ˜‰

#

But your work was important still, black-primer spurred the creation of mypy-primer whose ideas I stole for diff-shades haha ๐Ÿ˜„

#

Actually @neon loom as I've alluded to before, I'm going to need some help since I don't have an MacOS running machine. Are you up for it?

neon loom
#

I can give you SSH to my laptop if that makes it easier ...

bright glacier
#

Also the M1 compiled wheels are totally untested since we don't have access to M1 CI resources

neon loom
#

Do you have IPv6 enabled on your connection?

bright glacier
neon loom
#

๐Ÿ˜ฎ

bright glacier
neon loom
#

Ok. No problems. It's just encrypted remote shell/terminal access basically. Would let you copy files / use my m1 mac to do what you need (I'm using it as we speak too) ... Was planning on making you a non admin account + opening SSH directly to it for your IPv6 address if you had one. I could do IPv4 but it's more effort as I would have to port forward from my main router etc. and I have IPv4 off but default ... # legacy

#

For all those people who are like you need v4 (unfortunately I do for lame GItHub) I use NAT64 ... https://cooperlees.com/2020/12/nat64-using-jool-on-ubuntu-20-04/

I found that jool has very good tutorials, but all the commands to get going are hidden in these large tutorials. Here are the steps I took to get it working on Ubuntu 20.04 on both a Raspberry Pi + Protectli Vault. Please pre-read and refer to to Jool's Documentation for more information. I have...ยป

bright glacier
#

I've lived my life on IPv4. Not much of a networking nerd fwiw

neon loom
#

I'm actually ok @ networking, python is a side hobby that I am trying to be good at.

bright glacier
neon loom
#

No biggy. You just need me to build + run tests right?

#

GitHub actions can at least build x86_64 mypyc and test now? lets make an action to test mypyc?

bright glacier
#

I've been running the test suite for all of the environments supported, it's just the M1 wheels that can't be tested

late dewBOT
#

.github/workflows/build.yaml lines 83 to 87

CIBW_BEFORE_TEST: "pip install -r .mypyc-support/test-requirements.txt"
CIBW_TEST_COMMAND: 'pytest {project} -k "not incompatible_with_mypyc"'
CIBW_TEST_EXTRAS: "python2,d,jupyter"
# Skip trying to test arm64 builds on Intel Macs.
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"```
bright glacier
#

Linux, Windows and Intel MacOS all run the test suite (excluding some tests that break because mocks and monkeypatching aren't supported by mypyc) during the wheel build

tribal thistle
#

I wonder if I can spin up a couple machines on my host

#

Worst case scenario, I can write a simple circle CI or smthn

#

Have it deployed on all machines

bright glacier
# neon loom No biggy. You just need me to build + run tests right?

Yeah it should be that hopefully. We could run benchmarks on Mac too but it's not strictly necessary and can be quite fickle to do properly. Basically setup test environment, install wheel from the workflow. run pytest -k "not incompatible_with_mypyc", and run diff-shades and compare the produced data file to a known good one from main (I'll provide it). Oh do all of that again for M1.

#

I really need to come up with better instructions

neon loom
#

Can we shell script that so its all repeatable more reliably ๐Ÿ˜„

bright glacier
#

Good idea, especially since I want to invite members of the community to help out too

neon loom
#

(Y)

#

Whoops - ๐Ÿ‘

#

(That is a Facebook shortcut)

left lagoon
#

yes

neon loom
#

TIL - 148 files would be left unchanged in the cpython repo ๐Ÿ˜„

plain atlas
#

nice

neon loom
#

Didn't expect that many

hybrid island
#

probably some really small files, but still impressive

neon loom
#

Just running CI then wull have the PR up for #2407

#

*will

bright glacier
#

psf/black#2407

bright glacier
#

So wait, we're adding CPython to primer?

neon loom
#

Ya ya

bright glacier
#

I'm a little bit worried at how long CI is doing to take with that

neon loom
#

4 mins. And only on 3.9 (latest stable cpython so we can support as much syntax as possible) - I think the signal is very valuable. Already found more ESP bugs.

#

non ESP == 13 failed files - 16 with ESP

bright glacier
#

Ah ok that's good. Why do we run primer across multiple OSes and Python versions btw?

neon loom
#

Well - the 4 mins is on my Mac M1 maxed out. I may well be to slow for Actions. if so, will do it in a dedicated job in 3.9 only

bright glacier
#

To find these bugs?

neon loom
#

We've seen platform specific bugs, so running the same code across different OS's find these things.

bright glacier
#

Fair enough

flat krakenBOT
#
  • cpython tests is probably the best repo for black to test on as the stdlib's unittests should use all syntax
    • Limit to running in recent versions of the python runtime - e.g. today >= 3.9
      • This allows us to parse more syntax
  • Exclude all failing files for now
    • Definately have bugs to explore there - Refer to #2407 for more details there
    • Some test files on purpose have syntax errors, so we will never be able to parse them
  • Add new black command arguments logging in deb...
neon loom
#

Such a small amount of code for the hours of work. I hate we use a regex for excludes personally.

#

But a cool POC I feel, showing we can format a very high % of cpython. Some files we'll always have to exclude, but ~10 or so there we need to dig into

#

@bright glacier - Worth a change log? I was torn

#

I don't feel users care what repos we CI on

#

3.9 passed but 3.10 timed out:

[2021-08-15 23:08:36,091] ERROR: Running black for /tmp/primer.20210815225821/cpython timed out (['/opt/hostedtoolcache/Python/3.10.0-rc.1/x64/bin/black', '--experimental-string-processing', '--extend-exclude', 'Lib/lib2to3/tests/data/different_encoding.py|Lib/lib2to3/tests/data/false_encoding.py|Lib/lib2to3/tests/data/py2_test_grammar.py|Lib/test/bad_coding.py|Lib/test/bad_coding2.py|Lib/test/badsyntax_3131.py|Lib/test/badsyntax_pep3120.py|Lib/test/test_base64.py|Lib/test/test_exceptions.py|Lib/test/test_grammar.py|Lib/test/test_named_expressions.py|Lib/test/test_patma.py|Lib/test/test_tokenize.py|Lib/test/test_xml_etree.py|Lib/traceback.py|Tools/c-analyzer/c_parser/parser/_delim.py', '--check', '--diff', '.']) (lib.py:190)
bright glacier
neon loom
#

Seems I read wrong. They both timed out. Will allow 15 mins, if it can't pass reliably in 15 mins I'll disable for now.

bright glacier
#

Whelp I'm never running black-primer locally (or diff-shades once I add CPython) on a whim

#

it takes around ~30 minutes for me to a run through all of the primer projects

neon loom
#

You can always change the config ... I do when I play with stuff locally

bright glacier
#

Yup yep, for diff-shades I added simple include / exclude options for that

neon loom
#

I don't know what a diff-shared is and why we need so many tools

#

lol

#

*shades

bright glacier
#

diff-shades is basically me writing my own black-primer by stealing a bunch of ideas from mypy-primer

#

it's designed to compare two revisions of black

neon loom
#

Cool

bright glacier
#

I was going to use black-primer instead for my mypyc work but it wasn't ideal because primer can't easily tell you whether two revisions of black behave the same

#

it does a good job at testing black's stability and impact on projects as a whole BUT it just doesn't tell you a lot at a revision level

neon loom
#

Nope, didn't have that goal in mind when I wrote it. But I'd never be upset if something replaced it and did it all if it's of value etc.

bright glacier
#

Basically this is the sort of tooling I needed and wanted.

#

Pretty useful to see if a change is too disruptive or changes something it shouldn't ^^

#

Anyway, diff-shades was thrown together in a few days so the quality of the tool ain't great but I've been using it successfully for my mypyc work which makes me happy

neon loom
#

Yeah nice. That's how all good tools get started. primer can be replaced / re-written to do all this if needed.

#

Give up, going to be no sane way to run cpython. I limited it to Lib/* but still ~3m40s on my laptop. Not gonna happen. But I'd still like to merge the config for others to be able to use etc. if we ever want to debug the bugs it exposes.

#

Tis a shame. But ya never know unless you try.

#

Maybe we get rid of django and run cpython as the one large repo - it may work. But I think having the two large repos overloaded the i/o as I think it's running 2 at once (by default)

bright glacier
#

which IMO is not the best idea because black is parallelized anyway ^^

flat krakenBOT
bright glacier
#

Alright, let's try again at adding the test dependencies to Pipfile.lock, hopefully pipenv behaves this time ^^

#

Aw crap, the weird pytz issue is still happening, gosh this is annoying

#

I wonder if my weird environment setup is the cause

#

I'm now on attempt 4 I think?

plain atlas
#

at some point

#

I had commits

#

where my message was just 5

#

6, 7, 8

#

etc

#

because freaking github workflows don't have custom runners to test them

bright glacier
#

a commit history can tell a story ^^

plain atlas
#

...of not being able to count

bright glacier
#
83564ec5c (HEAD -> fix-messages, origin/fix-messages) This is ugly but special-casing this test seems fine
91ac7200b Only sys.exit(1) if an error occurred + fix one warning
0367ebf89 [mypyc] Emit messages regardless if there's no errors
plain atlas
#

attempt 1
attempt 2
attempt 3
attempt 5

bright glacier
#

"attempt idk but i swear this *should* work"

#

that's how you make a good commit history ๐Ÿ˜‰ /j

plain atlas
#

squash em afterwards

bright glacier
#

HECK YEA

#

pipenv didn't break the pytz dependency

#

damn is it sensitive to the environment tho

#

I had to move a virtual environment out of my CWD before running pipenv lock ๐Ÿ˜•

#

ugh, wth now the hashes aren't matching on 3.6

#

i'mma try again tomorrow, but at least i made progress :D

flat krakenBOT
#

At my company, we set the Python version in default_language_version
in each repo's .pre-commit-config.yaml,
so that all hooks are running with the same Python version.

However, this currently doesn't work for black,
as the language_version specified here
in the upstream .pre-commit-hooks.yaml takes precedence.
Currently, this requires us to manually set language_version
specifically for black,
duplicating the value from default_language_version.
The failure mode otherw...

bright glacier
#

bloody hell now the hashes work but the lock file isn't complete

#

Using the lock file on 3.6 for example breaks the documentation

#

Gosh I dislike pipenv more and more

little parrot
#

Oh I'm actually quite interested about this, black was one of the first projects I ever saw using poetry, why did you guys switch?

plain atlas
#

@bright glacier why are you using pipenv?

bright glacier
#

The switch happened before I even contributed to black

tribal thistle
#

Join the darkside - switch to poetry

#

I wonder hmm

#

Heh

#

Y'all probably aren't interested in using a full poetry build and release system, but that's why I have two branches

#

It's a bit outdated now, but this branch has a solid start for setting up poetry

#

The one that released the pypi package is poetry-build

plain atlas
little parrot
#

i must be entirely mis remembering cause i cant find poetry in the history anywhere

flat krakenBOT
#

It's finally happening :tada:, the initial work was done several years ago in GH-1009 by @ msullivan is now being followed through by yours truly. If this work doesn't find its way to PyPI eventually, I'll be disappointed :slightly_smiling_face:

Performance

I wrote an entire report which can be read here: https://gist.github.com/ichard26/b996ccf410422b44fcd80fb158e05b0d, but the TL;DR is:

  • Formatting with safety checks: 1.93x faster
  • Formatting without safety checks: ...
bright glacier
#

Finally! I got my mypyc PR up, I still have a lot of work to do, but this is a major milestone ducky_party

silent apex
#

If you need Windows testing, I can do that any time if you tell me what I'd have to do

bright glacier
#

Uh yeah, I need to come up with better instructions first as noted in the PR description first ๐Ÿ˜…

silent apex
#

Oh I uh, apparently can't read

bright glacier
#

Haha, no worries, I wrote perhaps too much :p

neon loom
austere lava
#

did pipenv solve the multi-platform problem already?

#

when going on windows you couldn't pipenv install because the lockfile sometimes had linux specific binaries

neon loom
#

It had a 2021.5.29 release ... and a commit 8 days ago - So getting more action that it use to

#

Has > 500 issues tho. Makes me feel better about black now

frozen badge
#

tbh i think something like pipenv is inherently more prone to bugs due to its critical and highll complex natuer

plain atlas
#

i mean

#

poetry also is complex

flat krakenBOT
#

Please add an changelog entry but other than that this seems fine to me. Thank you!

P.S. for added convience here's a diff you can use:

diff --git a/CHANGES.md b/CHANGES.md
index a678aae..a4b8e01 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,11 @@
 - Add support for formatting Jupyter Notebook files (#2357)
 - Move from `appdirs` dependency to `platformdirs` (#2375)
 
+### Integrations
+
+- The provided pre-commit hooks no longer specify `language_version` to avoi...
plain atlas
#

@bright glacier how do you push to a pr fork branch?

bright glacier
verbal iron
#
import os,time
os.system('cls')
moneygain = 1
money = 0
speed = 0
cost = 10
added = 1
add = 1
ps = True
while True:
    print(f'''
car speed:{speed}mph
cost to upgrade: ${cost} coins
money = ${money}
type (add) to gain ${moneygain}
type (upgrade) to add speed
''')
    commands = input(">")
    if commands == "add":
        money += moneygain
        os.system('cls')
    if commands != "add" or "upgrade":
        os.system('cls')
    if commands == "upgrade" and money >= cost:
        add += 1
        speed += add
        os.system('cls')
        money -= cost
        added += 1
        moneygain += added
        cost += 20

i made this game and here's the code I'm a beginner so please point out any mistakes

boreal nacelle
#

Is there you endlessly entering text?

#

@verbal iron

verbal iron
#

wdym

boreal nacelle
#

Write in full I'm not a English

verbal iron
#

ok

#

what do you mean

boreal nacelle
#

Like you have entered text into the console many times at the speed of a car?

#

@verbal iron

verbal iron
#

yes

boreal nacelle
#
import os,time
os.system('cls')
moneygain = 1
money = 0
speed = 0
cost = 10
added = 1
add = 1
ps = True
def main():
    print(f'''
car speed:{speed}mph
cost to upgrade: ${cost} coins
money = ${money}
type (add) to gain ${moneygain}
type (upgrade) to add speed
''')
    commands = input(">")
    if commands == "add":
        money += moneygain
        os.system('cls')
        main()
    if commands != "add" or "upgrade":
        os.system('cls')
        main()
    if commands == "upgrade":
        if money >= cost:
            add += 1
            speed += add
            os.system('cls')
            money -= cost
            added += 1
            moneygain += added
            cost += 20โ€Š
            main()
        else:
            print("Not enough coins")
            main()
main()```
#

Oh stop

verbal iron
#

that makes alot of sense

#

thanks

boreal nacelle
#

Stop

#

It's not working

#

Sorry idk:(

verbal iron
#

oh it was a good idea

faint haven
verbal iron
#

ok

graceful iris
#

hi i have downloaded python @modern lance ping me when u have a suggestion ๐Ÿ™‚

#

waht do i do now?

#

i want to learn how to code

#

oof wrong channel......

verbal iron
#

you can read books sign up for bootcamps and courses i dont recommend videos. reading books are very effective

#

@graceful iris

bright glacier
#

!resources

late dewBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

flat krakenBOT
flat krakenBOT
flat krakenBOT
#

Right the transformer code looks at the transformer's __name__ attribute when deciding to return early: https://github.com/psf/black/blob/ef7c45f28132a7704a4549072ce5b272034fa196/src/black/linegen.py#L964-L967

This is kinda hacky and becomes quite a problem when integrating mypyc since nested functions don't keep that attribute due a bug (https://github.com/mypyc/mypyc/issues/884). The current workaround is to dynamtically create a wrapping class at runtime (via type() mind you :upside_d...

graceful iris
potent bone
bright glacier
#

I'll note that this entire topic is off topic here: but real python is a good source of free articles. they're more piecemeal like so if you prefer more structured guided learning, they might not be a good bet starting out

graceful iris
#

ok

flat krakenBOT
#

Actually this doesn't go far enough, it didn't occur to me before but we actually support nested gitignores these days, and uhm, this PR doesn't fully fix the ungraceful crash when a nested gitignore is invalid.

โฏ tree -a test
test
โ”œโ”€โ”€ a
โ”‚ย ย  โ”œโ”€โ”€ a.py
โ”‚ย ย  โ””โ”€โ”€ .gitignore
โ””โ”€โ”€ a.py

1 directory, 3 files

~/programming/oss/black on gitignore [$?] via v3.8.5 (bm-venv) 
โฏ dropblackcache -y ; black test
no caching was found!
Could not parse test/a/.gitignore: Invalid git pat...
bright glacier
#

So wait, how many mini-projects am I running for psf/black again?

#
  • documentation
#
  • developer experience
plain atlas
#

I think its 4?

#

*40

bright glacier
#
  • tooling (blackbench, diff-shades)
#
  • mypyc
#
  • this isn't really a project but I'm trying to get the PR number down too
plain atlas
#

what are the other 35?

bright glacier
#

fortunately most of them don't exist :D

#

yet

#

I already have ideas of more stuff I could do, but I really need to limit myself from taking on more

plain atlas
#

hey, I'm working on 7 projects, could you help me with 10 of them? Again, just 12 need your assistance, so join me with working on 17 projects ty

#

๐Ÿ™ƒ

flat krakenBOT
neon loom
#

VSCode on demand!

#

And you can even have vim plugin!

#

No python / black plugins yet - Wonder if we can help make that happen somehow ๐Ÿ˜„

#

<3's VSCode

bright glacier
late dewBOT
#
You got it!

Your reminder will arrive <t:1629412535:R>!

late dewBOT
bright glacier
late dewBOT
#
Sure thing!

Your reminder will arrive <t:1629485233:R>!

flat krakenBOT
#

Describe the style change

Sometimes you need to access attributes deep within another object or with extremely long names, and Black helpfully tries to wrap the right hand side of the expression to avoid blowing the length limit, but doesn't touch the right.

Examples in the current Black style

(
    something.something_else.hideously_long_attribute_name.other_property.even_deeper.finally_getting_close.okay
) = 1

Desired style

plain atlas
#

TBH I always thought some of the purpose of blackd was to support configuration rules throughout an organisation without having to put the configuration on every repo

obsidian gale
#

Hello

#

What project are you guys working on

plain atlas
mossy light
late dewBOT
plain atlas
#

๐Ÿ‘€

#

hello ichard

bright glacier
#

Ah yeah the mentorship thingy

bright glacier
#

@dense jungle I'm reviewing PR psf/black#2414 for what is hopefully the last time. I'm pretty likely to approve and merge, but I wanted to let you give any feedback first.

bright glacier
#

Well, actually I guess we do have two PRs to consider. I prefer this one mostly because it hides away the traceback (which can be scary!) but that's just me.

bright glacier
#

Hmm, re psf/black#2412, I suppose the docker image we provide does fall under usage and configuration but it doesn't sit well with me.

toxic stormBOT
bright glacier
#

Thinking about it some more, the current location could work especially since we probably want to document the OS native binaries we also provide. A "Alternative installation" (please bikeshed this -- it's horrible :p) document could easily work.

dense jungle
bright glacier
#

Awesome, I'm happy to see the PR count go down ^^

#

Also I get to +1 my closed issue count so hooray ๐ŸŽ‰

dense jungle
#

oh no you're going to beat me

bright glacier
#

You still have a huge lead IIRC

#

Yep, ~40 lead still :p

plain atlas
#

brb creating 41 spam issues on psf/black (/s ofc) ๐Ÿ˜ผ

bright glacier
#

I'm using codespell to check my documentation changes now, so hopefully Jelle won't catch as many dumb typos these days :p

#

Ooo I should run diff-shades on psf/black#2278. I'm stil working on a markdown output but this PR should be a good experiment into whether it serves its mission as a mypy-primer for black well enough.

toxic stormBOT
bright glacier
#

Haha, you know that repository is quite active when CI is maxed out. Some jobs are in queue right now :p

#

Good timing as I got to go now for the time being ๐Ÿ˜„

flat krakenBOT
#

Describe the style change

Black does not currently clean trailing whitespace. This is strange, and does not jive well with any major Python linter I can find (say Pylint).

Additional context

The only reason I can think of to not do this now is backwards compatibility.

If ticket isn't immediately closed for being annoying to the dev team, I would happily implement it.

Thanks.

bright glacier
#

Wait what, does black not handle that ???

#

Eh, I'll triage it later ^^

plain atlas
bright glacier
#

heya, I'd appreciate reviews on the following PRs:

  • psf/black#2416 "document jupyter hook" (this one is the lowest priority since it looks OK to me)
  • psf/black#2412 "Docker image usage description"
  • psf/black#2384 "Stop changing return type annotations to tuples"
  • psf/black#2278 "Parenthesize conditional expressions"
bright glacier
#

RE. psf/black#1574 I think the best course of action would be to actually stop suggesting stable as much as possible and instead specify the current latest version. We can extend the script PR 2416 introduces that checks if the pre-commit rev value is correct to cover these cases too.

toxic stormBOT
bright glacier
#

Whelp, I was going to run diff-shades against the "Parenthesize conditional expressions" PR but it turns out diff-shades needs a lot more development before it's CI ready

#

While I like the changes for the most part, the fact we don't hug brackets is really bothering me

#

just feels like a lot of whitespace

plain atlas
#

hm

#

side note: anyone know of a toml formatter because my whitespace is wild in those

bright glacier
#
                 param = [
-                    processors[key](compiled_params[key])
-                    if key in processors
-                    else compiled_params[key]
+                    (
+                        processors[key](compiled_params[key])
+                        if key in processors
+                        else compiled_params[key]
+                    )
                     for key in positiontup
                  ]
#

eg. feels a bit wasteful here

#
         assert db_request.route_path.calls == [
-            pretend.call("manage.project.roles", project_name=project.name)
-            if desired_role == "Owner"
-            else pretend.call("packaging.project", name=project.name)
+            (
+                pretend.call("manage.project.roles", project_name=project.name)
+                if desired_role == "Owner"
+                else pretend.call("packaging.project", name=project.name)
+            )
          ]

ditto

plain atlas
#

inclined to agree tbh

#

which pr?

bright glacier
#
  • psf/black#2278 "Parenthesize conditional expressions"
toxic stormBOT
bright glacier
#

like there's a lot more cases where IMO it improves things, but the above two don't sit well with me, OTOH there's this:

-            lambda tab: tab.c.q.in_(vv)
-            if tab.name == "t1"
-            else tab.c.q.in_(qq),
+            lambda tab: (
+                tab.c.q.in_(vv) if tab.name == "t1" else tab.c.q.in_(qq)
+            ),

which is a massive improvement

plain atlas
#

otoh?

bright glacier
#

on the other hand

plain atlas
#

on the other hand

#

yesh

#

huh, pyanalyze

#

jelle ๐Ÿ‘€

bright glacier
#
-                    value="singular%d" % ii if ii % 4 == 0 else None
+                    value=("singular%d" % ii) if ii % 4 == 0 else None

ok this one is just cute even tho I don' think it's necessary :p

plain atlas
#

side note: does jelle work for quora?

bright glacier
#

IIRC yes.

plain atlas
bright glacier
#

You can hide your membership in an organization ^^

plain atlas
#

true, but it typically will say collaborator regardless of that

bright glacier
#

It won't actually

plain atlas
#

huh, possible til

bright glacier
#

Take a look here: pypa/bandersnatch#980

toxic stormBOT
bright glacier
#

Cooper and I are both maintainers, but his membership is private and mine isn't

#

Cooper probably says "contributor" for you, no?

plain atlas
#

yea

#

afk

#

ergh

late dewBOT
#

.github/workflows/ci.yml line 12

if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository```
plain atlas
#

yay

#

my isort and black are fighting

bright glacier
#

Probably need --profile black then

plain atlas
#

already is there--

#

are you

#

TIL

#

in the tox.ini file

#

if its profile = black it actually means nothing

#

it has to be profile=black

bright glacier
#

And one more reason why I hate INIs ^^

plain atlas
#

brb making a commit to protected main to fix this

#

because

#

yeah

#

also

#

king-arthur#2

toxic stormBOT
plain atlas
#

was #4

#

cc @delicate marsh, just sent a pr to fix it, again

#

whups

plain atlas
#

strangely

#

the line lengths are configured the same

#

and yet, they're fighting

bright glacier
#

How so?

plain atlas
#

isort:

from modmail.utils.threads import (
    Target, ThreadAlreadyExistsError, ThreadException, ThreadNotFoundError, Ticket, is_modmail_thread,
)

black:```py
from modmail.utils.threads import (
Target,
ThreadAlreadyExistsError,
ThreadException,
ThreadNotFoundError,
Ticket,
is_modmail_thread,
)

bright glacier
#

Oh that looks like the magic trailing comma thingy, IIRC there is an issue on the isort tracker about this, lemme find it.

plain atlas
#

nice thing is if I remove the trailing comma isort puts it back

bright glacier
#

pycqa/isort#1683

toxic stormBOT
plain atlas
#

well

#

lmao

#

solution: remove some of these imports since flake8 complains about them anyways

#

(since they aren't used in the code)

#

tl;dr currently doing a refactor of this file into multiple files since it deserves them

bright glacier
#

I just finished doing like the 6th? pipenv lock trying to add the test dependencies to the lockfile. I think the lockfile shouldn't be broken this time but I still need to test it.

#

I literally had to 1) do a clean clone of psf/black, 2) create a Python 3.6.12 virtualenv, and 3) rm Pipfile.lock before locking so it wouldn't misbehave. Lovely.

plain atlas
bright glacier
#

I might look into that soon, but this is probably still less work than moving to poetry.

#

Does poetry support custom build scripts like setuptools' setup.py?

#

If not, it will be a very unpleasant experience packaging up a Rust, C, and Python distribution.

#

Unless there's good plugins for that, but IDK.

little parrot
#

its in alpha or beta or something