Commit Graph

13 Commits

Author SHA1 Message Date
Jelle Zijlstra
ba88fc372e
Simplify string tokenization regexes (#4331) 2024-04-24 23:11:31 -07:00
Tushar Sadhwani
551ede2825
Add PEP 701 support (#3822)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: hauntsaninja <hauntsaninja@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-04-22 08:19:19 -07:00
Alex Waygood
69d49c5a6f
Bump mypy to 1.7.1 (#4069) 2023-11-24 06:19:54 -08:00
Shantanu
c1e30d97fe
Fix most blib2to3 lint (#3794) 2023-07-16 21:33:58 -07:00
Shantanu
0b4d7d55f7
Run pyupgrade on blib2to3 and src (#3771) 2023-07-09 15:05:01 -07:00
Shantanu
b4dca26c7d
Drop support for Python 3.7 (#3765) 2023-07-05 10:08:04 -07:00
Jelle Zijlstra
eb32729ab5
blib2to3: add a few annotations (#3675) 2023-05-03 10:26:57 -07:00
Jelle Zijlstra
a07871b9cd
Fix new mypy error in blib2to3 (#3674)
See python/mypy#15174
2023-05-03 08:43:20 -07:00
Yilei "Dolee" Yang
f265ff5bcd
Explicitly annotate this with Final[str] to make it work in mypyc 1.0.0+. (#3645) 2023-04-13 17:12:05 -07:00
Felix Hildén
799f76f537
Normalise string prefix order (#2297)
Closes #2171
2022-01-13 09:59:43 -08:00
Jelle Zijlstra
5e2bb528e0
Reduce usage of regex (#2644)
This removes all but one usage of the `regex` dependency. Tricky bits included:
- A bug in test_black.py where we were incorrectly using a character range. Fix also submitted separately in #2643.
- `tokenize.py` was the original use case for regex (#1047). The important bit is that we rely on `\w` to match anything valid in an identifier, and `re` fails to match a few characters as part of identifiers. My solution is to instead match all characters *except* those we know to mean something else in Python: whitespace and ASCII punctuation. This will make Black able to parse some invalid Python programs, like those that contain non-ASCII punctuation in the place of an identifier, but that seems fine to me.
- One import of `regex` remains, in `trans.py`. We use a recursive regex to parse f-strings, and only `regex` supports that. I haven't thought of a better fix there (except maybe writing a manual parser), so I'm leaving that for now.

My goal is to remove the `regex` dependency to reduce the risk of breakage due to dependencies and make life easier for users on platforms without wheels.
2021-11-30 18:01:36 -08:00
Richard Si
117891878e
Implementing mypyc support pt. 2 (#2431) 2021-11-15 20:24:16 -08: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