odwyersoftware / brunette Goto Github PK
View Code? Open in Web Editor NEW๐ค A best practice Python code formatter
๐ค A best practice Python code formatter
Or at the very least I wasn't able to get it through :-).
I tried in the setup.cfg file: target-version = py36
. But in click it will loop over the characters (p
, y
, 3
, 6
) and didn't find p
in the list py27
, py36
, ...
As such it failed.
So I tried to figure out how black is doing it and they need this setting: ['py36']
in their toml file.
Setting this value (with or without the quotes) in the setup.cfg failed as well...
How could I define the target version in the setup.cfg file?
Thanks!
Black supports pyproject.toml now but brunette does not seem to yet. Would be nice to have. Thanks!
brunette >= 2.6.0
is pinning black
to older versions, but in my (light) testing everything seems to work fine for me with black-22.3.0
. I assume there's some corner-case that my codebase isn't triggering. Would you be willing to share more details about what's going on? I'm happy to take a look at fixing it as keeping black
up to date is important for us. Thanks!
Hello, so far one needs to provide a .cgf
file with the --config
option, right?
Would it be possible to append an option for the --single-quotes
option right away?
Like creating an according click.Option()
and adding it here? ๐ค
I mean. I tried exactly this but I'm getting a TypeError
TypeError: main() got an unexpected keyword argument 'single_quotes'
My monkeypatching skills seem worthless here... any ideas?
pip install -U brunette
: v 0.1.7 installed.
The following commands I all ran in the latest cloned git master of brunette:
Reformat the current directory with default settings with black:
(base) E:\brunette>black .
reformatted E:\brunette\setup.py
reformatted E:\brunette\brunette\brunette.py
All done! โจ ๐ฐ โจ
2 files reformatted, 2 files left unchanged.
Same but with brunette:
(base) E:\brunette>brunette .
Using configuration from E:\brunette\setup.cfg.
.git ignored: matches the --exclude regular expression
E:\brunette\brunette\__init__.py already well formatted, good job.
E:\brunette\brunette\__main__.py already well formatted, good job.
E:\brunette\setup.py already well formatted, good job.
reformatted E:\brunette\brunette\brunette.py
All done! โจ ๐ฐ โจ
1 file reformatted, 3 files left unchanged.
Now use the config file provided within git:
(base) E:\brunette>brunette --config setup.cfg .
Using configuration from setup.cfg.
Traceback (most recent call last):
File "c:\programdata\miniconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\programdata\miniconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\ProgramData\Miniconda3\Scripts\brunette.exe\__main__.py", line 7, in <module>
File "c:\programdata\miniconda3\lib\site-packages\brunette\brunette.py", line 150, in main
return BLACK_MAIN()
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\programdata\miniconda3\lib\site-packages\click\decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\programdata\miniconda3\lib\site-packages\black.py", line 463, in main
p, root, include_regex, exclude_regex, report, get_gitignore(root)
File "c:\programdata\miniconda3\lib\site-packages\black.py", line 3559, in gen_python_files
assert root.is_absolute(), f"INTERNAL ERROR: `root` must be absolute but is {root}"
AssertionError: INTERNAL ERROR: `root` must be absolute but is .
Ok, maybe it's the directory?
(base) E:\brunette>brunette --config setup.cfg brunette
Using configuration from setup.cfg.
Traceback (most recent call last):
File "c:\programdata\miniconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\programdata\miniconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\ProgramData\Miniconda3\Scripts\brunette.exe\__main__.py", line 7, in <module>
File "c:\programdata\miniconda3\lib\site-packages\brunette\brunette.py", line 150, in main
return BLACK_MAIN()
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\programdata\miniconda3\lib\site-packages\click\decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\programdata\miniconda3\lib\site-packages\black.py", line 463, in main
p, root, include_regex, exclude_regex, report, get_gitignore(root)
File "c:\programdata\miniconda3\lib\site-packages\black.py", line 3559, in gen_python_files
assert root.is_absolute(), f"INTERNAL ERROR: `root` must be absolute but is {root}"
AssertionError: INTERNAL ERROR: `root` must be absolute but is .
Ok, maybe it needs to be absolute like it says in the error?
(base) E:\brunette>brunette --config setup.cfg e:\brunette
Using configuration from setup.cfg.
Traceback (most recent call last):
File "c:\programdata\miniconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\programdata\miniconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\ProgramData\Miniconda3\Scripts\brunette.exe\__main__.py", line 7, in <module>
File "c:\programdata\miniconda3\lib\site-packages\brunette\brunette.py", line 150, in main
return BLACK_MAIN()
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\programdata\miniconda3\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\programdata\miniconda3\lib\site-packages\click\decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\programdata\miniconda3\lib\site-packages\black.py", line 463, in main
p, root, include_regex, exclude_regex, report, get_gitignore(root)
File "c:\programdata\miniconda3\lib\site-packages\black.py", line 3559, in gen_python_files
assert root.is_absolute(), f"INTERNAL ERROR: `root` must be absolute but is {root}"
AssertionError: INTERNAL ERROR: `root` must be absolute but is .
I would like to exclude directories like */migrations/*
How to do this in setup.cfg?
On a fresh install:
ImportError: cannot import name 'PY36_VERSIONS' from 'black' (/venv/lib/python3.9/site-packages/black/init.py)
I'm not 100% here but --single-quotes
stopped working and i started getting some type errors and i think its related to some cmypy/cython optimizations they did.
I'm still investigating so a better bug report is hopefully coming soon.
black was refactored and separated into many files from version 21.5b1.
https://black.readthedocs.io/en/stable/change_log.html#b1
brunette has followed this black refactoring since version 0.2.2, therefore it requests the black version be more than and equal to 21.5b1.
brunette . --target-version py36 --config setup.cfg
(within the checked out brunette repo).
==> All single quotes are changed into double quotes.
Very likely this is because black is starting some kind of daemon process in which the black module is re-loaded... Causing the single-quote implementation you had to be ignored (again).
Hi,
isort supports both isort
and tool:isort
of the setup.cfg file. Can we also add support for both brunette
and tool:brunette
? Currently only tool:brunette
is supported AFAIK. It's a small change, but it would be more consistent with tools that don't use tool:
prefix in the setup.ini file.
Thanks!
Thank you for writing this wrapper for black
. I wanted to raise one small suggestion: your requirements file should not pin the black version.
Perhaps your tool can concern itself only with its compatibility with the parts of the Black api and application surface area that it needs to use, but aside from setting a minimum Black version (and possibly a max version, if necessary) I'd argue that you can leave the specific Black version up to your users.
I'm suggesting changing
requirements.txt
setuptools
wheel
black==20.8b1
click
to
setuptools
wheel
black>=20.8b1
click
Hopefully, you can pin the dev copy, so that formatting of brunette
source code remains fixed. Ie. hopefully there's nothing wrong with this change:
requirements-dev.txt
black==20.8b1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.