Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing mypyc support pt. 2 #2431

Merged
merged 28 commits into from
Nov 16, 2021
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9531e1b
Initial mypyc support changes
ichard26 Jun 6, 2021
6e9e0fb
Make the test suite usable for testing
ichard26 Jun 6, 2021
acb77f7
Fix mypyc KeyError on src/black/parsing.py
ichard26 Jun 12, 2021
a37fb77
Saves ~100 kB on my Linux machine :)
ichard26 Jun 30, 2021
2ccc774
Strings specific micro-optimization (1-10% perf boost)
ichard26 Jun 30, 2021
6f60e6e
Looks like I'll be marking more and more tests
ichard26 Jul 1, 2021
f508be4
Fix mypyc + Black on Windows
ichard26 Jul 10, 2021
94dcddb
Ask mypy to warn on unreachable code
ichard26 Jul 10, 2021
57a25ed
Clean up mypyc setup in setup.py
ichard26 Jul 10, 2021
8f42f28
Merge branch 'main' into mypyc-support-pt2
ichard26 Jul 17, 2021
f6a3e78
Initial mypyc optimizations - 5% faster parsing
ichard26 Jul 27, 2021
911d0d8
More parsing optimizations - 4% faster
ichard26 Jul 27, 2021
1f0df05
Just some cleanup
ichard26 Jul 31, 2021
58fbe9c
--version now indicates whether black is compiled
ichard26 Aug 1, 2021
c7de2ea
Round 3 of optimizations - 95% black + 5% blib2to3
ichard26 Aug 3, 2021
b956802
Merge branch 'main' into mypyc-support-pt2
ichard26 Aug 8, 2021
eaa4f6c
Fix crashes and errors since merge from main
ichard26 Aug 7, 2021
e9834e0
Mild hack so mypyc doesn't break diff-shades + cleanup
ichard26 Aug 11, 2021
f103dc0
Address feedback & cleanup comments
ichard26 Aug 21, 2021
5fc39fe
Merge branch 'main' into mypyc-support-pt2
ichard26 Oct 28, 2021
2f238ca
Skip a few more monkeypatching tests
ichard26 Oct 28, 2021
f561b0c
Bring back ignore for unused type ignore
ichard26 Oct 28, 2021
11b4f09
Merge branch 'main' into mypyc-support-pt2
ichard26 Oct 30, 2021
b0b3709
Merge branch 'main' into mypyc-support-pt2
ichard26 Oct 31, 2021
bb86dcf
Merge branch 'main' into mypyc-support-pt2
ichard26 Nov 14, 2021
5ef46f4
Optimizations + compatiblity fixes
ichard26 Nov 14, 2021
7c52cdb
Merge branch 'main' into mypyc-support-pt2
ichard26 Nov 14, 2021
f5f1099
Fix crash on PyPy by deoptimizing :(
ichard26 Nov 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into mypyc-support-pt2
ichard26 committed Oct 28, 2021
commit 5fc39feb764b947e091adf7e8a364c29a901a98c
12 changes: 6 additions & 6 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -35,10 +35,10 @@ check_untyped_defs=True
# No incremental mode
cache_dir=/dev/null

[mypy-aiohttp.*]
follow_imports=skip
[mypy-black_primer.*]
# Until we're not supporting 3.6 primer needs this
disallow_any_generics=False

[mypy-black]
# The following is because of `patch_click()`. Remove when
# we drop Python 3.6 support.
warn_unused_ignores=False
[mypy-tests.test_primer]
# Until we're not supporting 3.6 primer needs this
disallow_any_generics=False
10 changes: 6 additions & 4 deletions src/black/__init__.py
Original file line number Diff line number Diff line change
@@ -399,10 +399,10 @@ def main(
quiet: bool,
verbose: bool,
required_version: Optional[str],
include: Pattern,
exclude: Optional[Pattern],
extend_exclude: Optional[Pattern],
force_exclude: Optional[Pattern],
include: Pattern[str],
exclude: Optional[Pattern[str]],
extend_exclude: Optional[Pattern[str]],
force_exclude: Optional[Pattern[str]],
stdin_filename: Optional[str],
workers: int,
src: Tuple[str, ...],
@@ -666,6 +666,8 @@ def reformat_one(
report.failed(src, str(exc))


# diff-shades depends on being to monkeypatch this function to operate. I know it's
# not ideal, but this shouldn't cause any issues ... hopefully. ~ichard26
@mypyc_attr(patchable=True)
def reformat_many(
sources: Set[Path],
2 changes: 1 addition & 1 deletion src/black/linegen.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
import sys
from typing import Collection, Iterator, List, Optional, Set, Union

from black.nodes import WHITESPACE, STATEMENT, STANDALONE_COMMENT
from black.nodes import WHITESPACE, RARROW, STATEMENT, STANDALONE_COMMENT
from black.nodes import ASSIGNMENTS, OPENING_BRACKETS, CLOSING_BRACKETS
from black.nodes import Visitor, syms, first_child_is_arith, ensure_visible
from black.nodes import is_docstring, is_empty_tuple, is_one_tuple, is_one_tuple_between
4 changes: 2 additions & 2 deletions src/black/parsing.py
Original file line number Diff line number Diff line change
@@ -150,8 +150,8 @@ def parse_ast(src: str) -> Union[ast.AST, ast3.AST, ast27.AST]:
raise SyntaxError(first_error)


ast3_AST: Final[Type] = ast3.AST
ast27_AST: Final[Type] = ast27.AST
ast3_AST: Final[Type[ast3.AST]] = ast3.AST
ast27_AST: Final[Type[ast27.AST]] = ast27.AST


def stringify_ast(
8 changes: 5 additions & 3 deletions src/blib2to3/README
Original file line number Diff line number Diff line change
@@ -14,8 +14,10 @@ Reasons for forking:

Change Log:
- Changes default logger used by Driver
- Backported https://github.com/python/cpython/commit/8565f6b6db0fa9f65449b532a5056a98bad3dc37
and https://github.com/python/cpython/commit/62c35a8a8ff5854ed470b1c16a7a14f3bb80368c
to support all RHS expressions in annotated assignments as like in regular assignments
- Backported the following upstream parser changes:
- "bpo-42381: Allow walrus in set literals and set comprehensions (GH-23332)"
https://github.com/python/cpython/commit/cae60187cf7a7b26281d012e1952fafe4e2e97e9
- "bpo-42316: Allow unparenthesized walrus operator in indexes (GH-23317)"
https://github.com/python/cpython/commit/b0aba1fcdc3da952698d99aec2334faa79a8b68c
- Tweaks to help mypyc compile faster code (including inlining type information,
"Final-ing", etc.)
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.