Commit Graph

50 Commits

Author SHA1 Message Date
Richard Si
904fe94ceb
Add lower bound for aiohttp-cors + fix primer (#2231)
It appears sqlalchemy has recently reformatted their project with
Black 21.5b1.

Most of our dependencies have a lower bound and creating a test
environment with the oldest acceptable dependencies runs the full
Black test suite just fine. The only exception to this is aiohttp-cors.
It's unbounded and the oldest version 0.1.0 until 0.4.0 breaks the
test suite in such an old environment.

Failure with 0.1.0:

```
tests/test_blackd.py:10: in <module>
    import blackd
testenv/lib/python3.8/site-packages/blackd/__init__.py:12: in <module>
    import aiohttp_cors
testenv/lib/python3.8/site-packages/aiohttp_cors/__init__.py:29: in <module>
    from .urldispatcher_router_adapter import UrlDistatcherRouterAdapter
testenv/lib/python3.8/site-packages/aiohttp_cors/urldispatcher_router_adapter.py:27: in <module>
    class UrlDistatcherRouterAdapter(RouterAdapter):
testenv/lib/python3.8/site-packages/aiohttp_cors/urldispatcher_router_adapter.py:32: in UrlDistatcherRouterAdapter
    def route_methods(self, route: web.Route):
E   AttributeError: module 'aiohttp.web' has no attribute 'Route'
```

For 0.2.0:

```
tests/test_blackd.py:10: in <module>
    import blackd
testenv/lib/python3.8/site-packages/blackd/__init__.py:12: in <module>
    import aiohttp_cors
testenv/lib/python3.8/site-packages/aiohttp_cors/__init__.py:27: in <module>
    from .cors_config import CorsConfig
testenv/lib/python3.8/site-packages/aiohttp_cors/cors_config.py:24: in <module>
    from .urldispatcher_router_adapter import UrlDistatcherRouterAdapter
testenv/lib/python3.8/site-packages/aiohttp_cors/urldispatcher_router_adapter.py:27: in <module>
    class UrlDistatcherRouterAdapter(AbstractRouterAdapter):
testenv/lib/python3.8/site-packages/aiohttp_cors/urldispatcher_router_adapter.py:32: in UrlDistatcherRouterAdapter
    def route_methods(self, route: web.Route):
E   AttributeError: module 'aiohttp.web' has no attribute 'Route'
```

For 0.3.0:

```
ERROR: Cannot install aiohttp-cors==0.3.0 and aiohttp==3.6.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested aiohttp==3.6.0
    aiohttp-cors 0.3.0 depends on aiohttp<=0.20.2 and >=0.18.0

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
```
2021-05-13 12:30:34 -07:00
Panagiotis Vasilopoulos
06ccb88bf2
Replace references to master branch (#2210)
Commit history before merge:

* Replace references to master branch
* Update .flake8 to reference docs on RTD

  We're moving away from GitHub as a documentation host to only RTD because
  it's makes our lives easier creating good docs. I know this link is dead right now,
  but it won't be once we release a new version with the documentation reorganization
  changes (which should be soon!).

  Co-authored-by: Richard Si <63936253+ichard26@users.noreply.github.com>
2021-05-09 17:50:17 -04:00
Łukasz Langa
d0e06b53b0
Mark blackd tests with the blackd optional marker (#2204)
This is a follow-up of #2203 that uses a pytest marker instead of a bunch of
`skipUnless`.  Similarly to the Python 2 tests, they are running by default and
will crash on an unsuspecting contributor with missing dependencies.  This is
by design, we WANT contributors to test everything.  Unless we actually don't
and then we can run:

  pytest --run-optional=no_blackd

Relatedly, bump required aiohttp to 3.6.0 at least to get rid of expected
failures on Python 3.8 (see 6b5eb7d465).
2021-05-07 16:33:36 +02:00
Miro Hrončok
76e1602d60
Install primer.json (used by black-primer by default) with black (#2154)
Fixes https://github.com/psf/black/issues/2153
2021-04-27 08:58:39 -07:00
Łukasz Langa
a0b4e609a7
Bump pathspec to >= 0.8.1 to solve invalid .gitignore exclusion handling (#2084)
Also made the Click requirement in Pipfile consistent with setup.py and bumped mypy.
2021-04-26 21:22:25 +02:00
KotlinIsland
ed9d58b741 don't require typed-ast 2021-04-01 17:38:04 +02:00
Hugo van Kemenade
24418a5450
Black requires Python 3.6.2+ (#1668) 2021-03-04 05:59:31 -08:00
Taneli Hukkinen
966baaacbc
Only require typing-extensions if Python < 3.8 (#1873) 2021-01-03 08:14:59 -08:00
Hugo van Kemenade
60de5bbc32
Bump typed-ast to fix for s390x (#1892)
* Bump typed-ast to fix for s390x

* pipenv install typed-ast==1.4.2
2020-12-31 09:07:31 -08:00
Hadi Alqattan
dd2f86ac0a
Support stable Python3.9. (#1748)
* Support stable Python3.9.

* Get back to 3.9-dev

* Add py39 to black usage.

* remove 3.9 temporarily.
2020-10-08 14:13:13 -07:00
Łukasz Langa
3ae83c3090
Make dependency on Click 7.0, regex 2020.1.8, and toml 0.10.1 explicit 2020-08-26 17:16:26 +02:00
Cooper Lees
b50a52708c
Add primer CI tool 🏴 (#1402)
* Add primer CI tool 💩
- Run in PATH `black` binary on configured projects
- Can set wether we expect changes or not per project
- Can set what python versions are supported for a project
- if `long_checkout` True project will not be ran on CI

Will add to CI after I finish unit tests to avoid silly bugs I'm sure I have 🤪

Tests:
- Manual Run - Will add unit tests if people think it will be useful
- Output:

```shell
(b) cooper-mbp1:black cooper$ time /tmp/b/bin/black-primer -k -w /tmp/cooper_primer_1
[2020-05-10 08:48:25,696] INFO: 4 projects to run black over (lib.py:212)
[2020-05-10 08:48:25,697] INFO: Skipping aioexabgp as it's disabled via config (lib.py:166)
[2020-05-10 08:48:25,699] INFO: Skipping bandersnatch as it's disabled via config (lib.py:166)
[2020-05-10 08:48:28,676] INFO: Analyzing results (lib.py:225)
-- primer results 📊 --

2 / 4 succeeded (50.0%) 
0 / 4 FAILED (0.0%) 💩
 - 2 projects Disabled by config
 - 0 projects skipped due to Python Version
 - 0 skipped due to long checkout

real	0m3.304s
user	0m9.529s
sys	0m1.019s
```

- ls of /tmp/cooper_primer_1
```
(b) cooper-mbp1:black cooper$ ls -lh /tmp/cooper_primer_1
total 0
drwxr-xr-x  21 cooper  wheel   672B May 10 08:48 attrs
drwxr-xr-x  14 cooper  wheel   448B May 10 08:48 flake8-bugbear
```

* Address mypy 3.6 type errors
- Don't use asyncio.run() ... go back to the past :P
- Refactor results into a named tuple of two dicts to avoid typing nightmare
- Fix some variable names
- Fix bug with rebase logic in git_checkout_or_rebase

* Prettier the JSON config file for primer

* Delete projects when finished, move dir to be timestamped + shallow copy

* Re-enable disabled projects post @JelleZijlstra's docstring fix

* Workaround for future annotations until someone tells me the correct fix
2020-05-16 17:36:20 -07:00
Nathan Hunt
3de8524de6
Add py.typed file. (#1395)
* Add py.typed file
2020-05-08 09:53:07 -07:00
Cooper Lees
2082a325fd
Refactor black into packages in src/ dir (#1376)
- Move black.py to src/black/__init__.py
- Have setuptools_scm make src/_black_version.py and exclude from git
- Move blackd.py to src/blackd/__init__.py
- Move blib2to3/ to src/
- Update `setup.py`
- Update unittests to pass
  - Mostly path fixing + resolving
- Update CI
  - pre-commit config
  - appveyor + travis

Tested on my mac with python 3.7.5 via:
```
python3 -m venv /tmp/tb3
/tmp/tb3/bin/pip install --upgrade setuptools pip coverage pre-commit
/tmp/tb2/bin/pip install ~/repos/black/
cd ~/repos/black/
/tmp/tb2/bin/coverage run tests/test_black.py
/tmp/tb3/bin/pre-commit run -a
/tmp/tb3/bin/black --help
/tmp/tb3/bin/black ~/repos/ptr/ptr.py
```
2020-05-08 08:50:50 -07:00
Ville Skyttä
26c9465a22
Add Change Log project URL (#1382)
* Add Change Log project URL

Co-authored-by: Cooper Lees <me@cooperlees.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-05-08 06:40:56 -07:00
Douglas Thor
8d6d92aa5b
Add option for printing a colored diff (#1266) 2020-05-08 14:30:10 +01:00
Jon Dufresne
1382eabb3f
Remove deprecated use of 'setup.py test' (#1275)
Since setuptools v41.5.0 (27 Oct 2019), the 'test' command is formally
deprecated and should not be used. Now use unittest as the test entry
point.
2020-05-08 06:23:50 -07:00
Cooper Lees
d29303c988
Split out Change Log (#1117)
* Split out Change Log
- Move to CHANGES.md to allow bots to see changes
- MANIFEST.in already includes *.md so CHANGES.md will be included
- THis maintains format but the change log will now be after acknowledgements
- This also ensure this gets added to pypi.org via setup.py function
2020-03-04 16:40:48 +01:00
Mr. Outis
9ef8e6c9b0 bump regex version, providing wheels (#1232)
Close #1112
2020-01-18 07:12:24 -08:00
Hugo van Kemenade
7af619b8c1 Skip the broken version of regex (#1209) 2019-12-16 13:46:43 -08:00
Michael J. Sullivan
3e60f6d454 Support compilation with mypyc (#1009)
* Make most of blib2to3 directly typed and mypyc-compatible

This used a combination of retype and pytype's merge-pyi to do the
initial merges of the stubs, which then required manual tweaking to
make actually typecheck and work with mypyc.

Co-authored-by: Sanjit Kalapatapu <sanjitkal@gmail.com>
Co-authored-by: Michael J. Sullivan <sully@msully.net>

* Make black able to compile and run with mypyc

The changes made fall into a couple categories:
 * Fixing actual type mistakes that slip through the cracks
 * Working around a couple mypy bugs (the most annoying of which being
   that we need to add type annotations in a number of places where
   variables are initialized to None)

Co-authored-by: Sanjit Kalapatapu <sanjitkal@gmail.com>
Co-authored-by: Michael J. Sullivan <sully@msully.net>
2019-10-30 07:29:29 -07:00
Michael J. Sullivan
31f4105731 Switch from attrs to dataclasses (#1116)
The main motivation here is that mypyc is going to have custom support
for dataclasses but probably not attrs.
2019-10-29 21:06:34 -07:00
Łukasz Langa
6bedb5c58a
Remove Poetry metadata 2019-10-28 23:02:39 +01:00
Łukasz Langa
b65af236cf
Upgrade typed-ast to 1.4.0 2019-10-28 14:09:57 +01:00
Michael McClimon
8ea13474a6 setup.py: rename _version.py to _black_version.py (#1089)
In #1082, _version.py was renamed to _black_version.py, but the
py_modules line in setup.py wasn't changed, which meant that when
installed from source, running it failed with something like:

```
Traceback (most recent call last):
  File "~/.pyenv/versions/3.6.5/bin/black", line 5, in <module>
    from black import patched_main
  File "~/.pyenv/versions/3.6.5/lib/python3.6/site-packages/black.py", line 55, in <module>
    from _black_version import version as __version__
ModuleNotFoundError: No module named '_black_version'
```
2019-10-23 21:15:12 -07:00
Łukasz Langa
a701659da2
s/_version.py/_black_version.py/ (#1082)
Some users are installing Black as a dependency in their project. Having
a _version.py in site-packages is asking for a conflict sooner or later.

Ideally we shouldn't require a separate version file at all, that's an
additional import we need to make. But I'll leave that bikeshedding for
a different time.
2019-10-21 15:03:01 +02:00
jgirardet
e9d4e7b67f add gitignore support using pathspec (#878) 2019-10-21 11:44:53 +02:00
Hugo van Kemenade
be35b1ed2d Declare support for Python 3.8 (#1069) 2019-10-15 10:08:44 -07:00
Andrey
6aef6c9d45 #455 Fix bug with tricky unicode symbols (#1047)
* add test for special unicode symbol which usual re can not process correctly
add regex lib which supports unicode 12.1.0 standard
replace re usage in project in favor to regex

* #455 fix dependency
2019-10-13 10:21:15 -07:00
vezeli
5938106ac4 Switch from versioneer to setuptools-scm (#1008) 2019-09-18 13:34:20 +01:00
Zsolt Dollenstein
025d2ca4ba
use versioneer to manage __version__ (#981) 2019-08-21 15:42:30 +02:00
Zsolt Dollenstein
77b6ed1b70 Hello github.com/psf! 2019-07-22 21:41:45 +01:00
Jason Fried
866be06646 Make --safe work for Python2.7 syntax, by using typed_ast for safe validation (#840) 2019-05-08 07:45:59 -07:00
Hugo
4a953b7241 ambv/black -> python/black (#819) 2019-05-02 20:19:52 +01:00
Jelle Zijlstra
a00f426637 add missing aiohttp dep (#699)
add missing aiohttp dep

Also mark 3.8 as allowed to fail for now; it will fail due to an aiohttp bug.

Fixes #690
2019-02-14 20:23:56 +00:00
Chuck Wooters
5c2dd96a69 patch main to ensure click_patch() gets called (#572) 2018-10-29 11:10:32 +01:00
Łukasz Langa
ed9b31b139
Require attrs >= 18.1.0 to work around ctypes failure in Vim
Fixes #116, #539
2018-09-27 07:49:04 -07:00
Zsolt Dollenstein
a82f186787 blackd: a HTTP server for blackening (#460) 2018-09-17 10:02:25 -07:00
Jon Dufresne
25795c9ff5 Add trove classifier for Python 3.7 support (#486)
Testing added in 3bdd423891.
2018-08-28 13:00:57 +01:00
Łukasz Langa
75eb91443e It works better when dependencies are installed. Who knew? 2018-06-06 17:13:51 -07:00
Stavros Korokithakis
3272bbc8b3 Specify the minimum click version (#284) 2018-05-31 10:46:05 -07:00
Łukasz Langa
7395f55564 18.5b0 2018-05-17 17:32:43 -07:00
Zsolt Dollenstein
1885721182 fix type errors in setup.py (#179) 2018-04-29 00:50:08 -07:00
Jonas Obrist
639b62dcd3 Added caching (#136)
Black will cache already formatted files using their file size and
modification timestamp. The cache is per-user and will always be used
unless Black is used with --diff or with code provided via standard
input.
2018-04-18 17:27:07 -07:00
Zsolt Dollenstein
80bd2b3134 Normalize string quotes (#75)
* Normalize string quotes

Convert single-quoted strings to double-quoted. Convert triple single-quoted strings to triple double-quoted. Do not touch any strings where conversion would increase the number of backslashes.

Fixes #51.

* reformat Black itself
2018-03-31 11:21:25 -07:00
Łukasz Langa
c7c8c4f501 Pin attrs to >=17.4.0 for @dataclass use
Fixes #54
2018-03-21 18:01:07 -07:00
Łukasz Langa
64aae0e57d Native README.md support on PyPI \o/
See: https://dustingram.com/articles/2018/03/16/markdown-descriptions-on-pypi
2018-03-17 01:26:30 -07:00
Hugo
76e6acb9ca Add Python 3-only classifier
https://pypi.python.org/pypi?%3Aaction=list_classifiers
2018-03-15 11:09:19 -07:00
Łukasz Langa
b1075f8b02 Include Grammar.txt in the distribution 2018-03-14 14:16:34 -07:00
Łukasz Langa
e74117f172 Initial commit 2018-03-14 12:55:32 -07:00