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

Support py38-style starred expressions in return statement #1121

Merged
merged 5 commits into from
Jan 18, 2020

Conversation

vemel
Copy link
Contributor

@vemel vemel commented Oct 30, 2019

Goal

#1091

Support py38 starred expressions in return and yield statements. Bug description

def starred_return():
    my_list = ["value2", "value3"]
    return "value1", *my_list

Investigation

Event the newest plib2to3 grammar does not support starred expressions in return statements, so switching to a new version will not solve the issue.

The idea is to use return_stmt: 'return' [testlist_star_expr] in Grammar.txt to support both old and new return statements.

Changes

  • Accept starred expressions in return_stmt
  • Accept starred expressions in yield_stmt
  • Add test test_python38

Not done

  • I did not add it as a new Feature so it does not require --target-version=py38, as it is more of a bug

tests/test_black.py Outdated Show resolved Hide resolved
@vemel
Copy link
Contributor Author

vemel commented Oct 30, 2019

Fixed flake8 warning.

@JelleZijlstra JelleZijlstra merged commit be49ac7 into psf:master Jan 18, 2020
blueyed added a commit to blueyed/pytest that referenced this pull request Jan 23, 2020
Note: black cannot parse `return *active_fixture_argnames,
*self.argnames` yet (fixed in master, psf/black#1121).

Tested manually using:
```python
@pytest.fixture(scope="session")
def xdist_suffix(request):
    print("\nxdist_suffix")
    suffixes.append("xdist")

@pytest.fixture(scope="session")
def parallel_suffix(tox_suffix, xdist_suffix):
    pass

def test_suffix(parallel_suffix):
    assert suffixes == ["tox", "xdist"]
```

When using a set there the order is not deterministic, i.e. the test is
flaky.
blueyed added a commit to blueyed/pytest that referenced this pull request Jan 25, 2020
Note: black cannot parse `return *active_fixture_argnames,
*self.argnames` yet (fixed in master, psf/black#1121).

Tested manually using:
```python
@pytest.fixture(scope="session")
def xdist_suffix(request):
    print("\nxdist_suffix")
    suffixes.append("xdist")

@pytest.fixture(scope="session")
def parallel_suffix(tox_suffix, xdist_suffix):
    pass

def test_suffix(parallel_suffix):
    assert suffixes == ["tox", "xdist"]
```

When using a set there the order is not deterministic, i.e. the test is
flaky.
blueyed added a commit to blueyed/pytest that referenced this pull request Mar 9, 2020
Note: black cannot parse `return *active_fixture_argnames,
*self.argnames` yet (fixed in master, psf/black#1121).

Tested manually using:
```python
@pytest.fixture(scope="session")
def xdist_suffix(request):
    print("\nxdist_suffix")
    suffixes.append("xdist")

@pytest.fixture(scope="session")
def parallel_suffix(tox_suffix, xdist_suffix):
    pass

def test_suffix(parallel_suffix):
    assert suffixes == ["tox", "xdist"]
```

When using a set there the order is not deterministic, i.e. the test is
flaky.
blueyed added a commit to blueyed/pytest that referenced this pull request Mar 31, 2020
Note: black cannot parse `return *active_fixture_argnames,
*self.argnames` yet (fixed in master, psf/black#1121).

Tested manually using:
```python
@pytest.fixture(scope="session")
def xdist_suffix(request):
    print("\nxdist_suffix")
    suffixes.append("xdist")

@pytest.fixture(scope="session")
def parallel_suffix(tox_suffix, xdist_suffix):
    pass

def test_suffix(parallel_suffix):
    assert suffixes == ["tox", "xdist"]
```

When using a set there the order is not deterministic, i.e. the test is
flaky.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants