Merge branch 'main' into 241a1really
This commit is contained in:
commit
3fd83e08e7
4
.github/workflows/diff_shades.yml
vendored
4
.github/workflows/diff_shades.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.11"
|
python-version: "3.11"
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ jobs:
|
|||||||
# The baseline revision could be rather old so a full clone is ideal.
|
# The baseline revision could be rather old so a full clone is ideal.
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "3.11"
|
python-version: "3.11"
|
||||||
|
|
||||||
|
2
.github/workflows/diff_shades_comment.yml
vendored
2
.github/workflows/diff_shades_comment.yml
vendored
@ -13,7 +13,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "*"
|
python-version: "*"
|
||||||
|
|
||||||
|
2
.github/workflows/doc.yml
vendored
2
.github/workflows/doc.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up latest Python
|
- name: Set up latest Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "*"
|
python-version: "*"
|
||||||
|
|
||||||
|
2
.github/workflows/fuzz.yml
vendored
2
.github/workflows/fuzz.yml
vendored
@ -28,7 +28,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Set up latest Python
|
- name: Set up latest Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "*"
|
python-version: "*"
|
||||||
|
|
||||||
|
2
.github/workflows/pypi_upload.yml
vendored
2
.github/workflows/pypi_upload.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up latest Python
|
- name: Set up latest Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "*"
|
python-version: "*"
|
||||||
|
|
||||||
|
2
.github/workflows/release_tests.yml
vendored
2
.github/workflows/release_tests.yml
vendored
@ -34,7 +34,7 @@ jobs:
|
|||||||
# Give us all history, branches and tags
|
# Give us all history, branches and tags
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
allow-prereleases: true
|
allow-prereleases: true
|
||||||
|
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -38,7 +38,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up latest Python
|
- name: Set up latest Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "*"
|
python-version: "*"
|
||||||
|
|
||||||
|
2
.github/workflows/upload_binary.yml
vendored
2
.github/workflows/upload_binary.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up latest Python
|
- name: Set up latest Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: "*"
|
python-version: "*"
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
- Allow empty lines at the beginning of all blocks, except immediately before a
|
- Allow empty lines at the beginning of all blocks, except immediately before a
|
||||||
docstring (#4060)
|
docstring (#4060)
|
||||||
- Fix crash in preview mode when using a short `--line-length` (#4086)
|
- Fix crash in preview mode when using a short `--line-length` (#4086)
|
||||||
|
- Keep suites consisting of only an ellipsis on their own lines if they are not
|
||||||
|
functions or class definitions (#4066)
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ def visit_match_case(self, node: Node) -> Iterator[Line]:
|
|||||||
|
|
||||||
def visit_suite(self, node: Node) -> Iterator[Line]:
|
def visit_suite(self, node: Node) -> Iterator[Line]:
|
||||||
"""Visit a suite."""
|
"""Visit a suite."""
|
||||||
if is_stub_suite(node):
|
if is_stub_suite(node, self.mode):
|
||||||
yield from self.visit(node.children[2])
|
yield from self.visit(node.children[2])
|
||||||
else:
|
else:
|
||||||
yield from self.visit_default(node)
|
yield from self.visit_default(node)
|
||||||
@ -303,7 +303,7 @@ def visit_simple_stmt(self, node: Node) -> Iterator[Line]:
|
|||||||
yield from self.line(-1)
|
yield from self.line(-1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not node.parent or not is_stub_suite(node.parent):
|
if not node.parent or not is_stub_suite(node.parent, self.mode):
|
||||||
yield from self.line()
|
yield from self.line()
|
||||||
yield from self.visit_default(node)
|
yield from self.visit_default(node)
|
||||||
|
|
||||||
|
@ -828,7 +828,7 @@ def is_line_short_enough( # noqa: C901
|
|||||||
if not line_str:
|
if not line_str:
|
||||||
line_str = line_to_string(line)
|
line_str = line_to_string(line)
|
||||||
|
|
||||||
width = str_width if mode.preview else len
|
width = str_width if Preview.respect_east_asian_width in mode else len
|
||||||
|
|
||||||
if line.contains_standalone_comments():
|
if line.contains_standalone_comments():
|
||||||
return False
|
return False
|
||||||
|
@ -735,8 +735,15 @@ def is_funcdef(node: Node) -> bool:
|
|||||||
return node.type == syms.funcdef
|
return node.type == syms.funcdef
|
||||||
|
|
||||||
|
|
||||||
def is_stub_suite(node: Node) -> bool:
|
def is_stub_suite(node: Node, mode: Mode) -> bool:
|
||||||
"""Return True if `node` is a suite with a stub body."""
|
"""Return True if `node` is a suite with a stub body."""
|
||||||
|
if node.parent is not None:
|
||||||
|
if Preview.dummy_implementations in mode and node.parent.type not in (
|
||||||
|
syms.funcdef,
|
||||||
|
syms.async_funcdef,
|
||||||
|
syms.classdef,
|
||||||
|
):
|
||||||
|
return False
|
||||||
|
|
||||||
# If there is a comment, we want to keep it.
|
# If there is a comment, we want to keep it.
|
||||||
if node.prefix.strip():
|
if node.prefix.strip():
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
# flags: --preview
|
# flags: --preview
|
||||||
from typing import NoReturn, Protocol, Union, overload
|
from typing import NoReturn, Protocol, Union, overload
|
||||||
|
|
||||||
|
class Empty:
|
||||||
|
...
|
||||||
|
|
||||||
def dummy(a): ...
|
def dummy(a): ...
|
||||||
def other(b): ...
|
async def other(b): ...
|
||||||
|
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
@ -48,13 +50,22 @@ def b(arg: Union[int, str, object]) -> Union[int, str]:
|
|||||||
raise TypeError
|
raise TypeError
|
||||||
return arg
|
return arg
|
||||||
|
|
||||||
|
def has_comment():
|
||||||
|
... # still a dummy
|
||||||
|
|
||||||
|
if some_condition:
|
||||||
|
...
|
||||||
|
|
||||||
# output
|
# output
|
||||||
|
|
||||||
from typing import NoReturn, Protocol, Union, overload
|
from typing import NoReturn, Protocol, Union, overload
|
||||||
|
|
||||||
|
|
||||||
|
class Empty: ...
|
||||||
|
|
||||||
|
|
||||||
def dummy(a): ...
|
def dummy(a): ...
|
||||||
def other(b): ...
|
async def other(b): ...
|
||||||
|
|
||||||
|
|
||||||
@overload
|
@overload
|
||||||
@ -98,3 +109,10 @@ def b(arg: Union[int, str, object]) -> Union[int, str]:
|
|||||||
if not isinstance(arg, (int, str)):
|
if not isinstance(arg, (int, str)):
|
||||||
raise TypeError
|
raise TypeError
|
||||||
return arg
|
return arg
|
||||||
|
|
||||||
|
|
||||||
|
def has_comment(): ... # still a dummy
|
||||||
|
|
||||||
|
|
||||||
|
if some_condition:
|
||||||
|
...
|
||||||
|
Loading…
Reference in New Issue
Block a user