peterjc / flake8-black

flake8 plugin to run black for checking Python coding style
MIT License
165 stars 10 forks source link

Problems with line length #68

Closed proggga closed 5 months ago

proggga commented 2 years ago

Hi, I have a problem, I haven't pyproject.toml file, at all. I had everything in .flake8 and now for configure flake8 plugin I need to use strange file. Nothing worked. Please help, how should I create this file I've made this one `

cat pyproject.toml

[tool.poetry.dev-dependencies] black = { line_length = 120, version = "*", allow-prereleases = true } ` but this doesn't work

I even add file to flake8 config but still no hope ╰─ cat .flake8 [flake8] max-line-length = 120 exclude=alembic per-file-ignores=__init__.py:F401 extend-ignore=B008 black-config = pyproject.toml

I have 2 suggestions:

  1. please add to documentation how to do it for a teapot
  2. add option to plugin line "--use-flake8-config" because I have small config and I don't really need second one with only 1 line
peterjc commented 2 years ago

I see now that the URL for how to configure black needed updating, fixed in b03ca0a2d40c6a33b9d16796f246cac81776ba3c - thank you.

Based on their example for what to put in pyproject.toml, try this:

[tool.black]
line-length = 120

Personally however I just run black with the default line length.

Q1: I'm not familiar with teapot, or how it is related to flake8 - do you mean this? https://pypi.org/project/teapot/

Q2: I don't think that would be helpful. The very early versions of flake8-black used the flake8 max-line-length as the black line length. This worked but became a problem as soon as you try to run black directly. At that point you either run black -l 120 ... every time, or just set the black configuration. So on balance it seems far better to just have the the flake8-black also use the black configuration.

proggga commented 2 years ago

Oh man, thanks, now I get it.

About "teapot", sorry for that, this is ru idiom means "little stupid/beginner/rookie" analog in en "books for dummies" in ru it's like books for teapot, sorry i totally forget about this one

Maybe you also can add example of config to readme

peterjc commented 5 months ago

I'm closing this issue now - I'm not sure if you were suggesting this, but I'd rather not give examples of how to configure black here.

If you had something else in mind, I'm happy to reopen this though.