Wrap multiple context managers in parentheses when targeting Python 3.9+#3489
Merged
Conversation
Contributor
Author
|
I manually ran First example: ╭──────────────────────── Summary ─────────────────────────╮
│ 12 projects & 29 files changed / 608 changes [+347/-261] │
│ │
│ ... out of 2 384 528 lines, 11 521 files & 23 projects │
╰──────────────────────────────────────────────────────────╯
[aioexabgp - https://github.com/cooperlees/aioexabgp.git]
╰─> revision fc83c5c705e3c818934ce0cdd04d6169a6977996
--- a/aioexabgp:aioexabgp/tests/fibs_tests.py
+++ b/aioexabgp:aioexabgp/tests/fibs_tests.py
@@ -190,31 +190,37 @@
)
)
def test_del_all_routes(self) -> None:
# Test delete all with a nexthop
- with patch(
- f"{BASE_MODULE}.LinuxFib.get_route_table",
- fibs_tests_fixtures.mocked_get_route_table,
- ), patch(
- f"{BASE_MODULE}.LinuxFib.del_route", return_value=True
- ) as mock_del_route:
+ with (
+ patch(
+ f"{BASE_MODULE}.LinuxFib.get_route_table",
+ fibs_tests_fixtures.mocked_get_route_table,
+ ),
+ patch(
+ f"{BASE_MODULE}.LinuxFib.del_route", return_value=True
+ ) as mock_del_route,
+ ):
self.assertTrue(
self.loop.run_until_complete(
self.lfib.del_all_routes(ip_address("fd00::4"))
)
)
# 1 prefix/route from v4 and 1 from v6 table
self.assertEqual(2, mock_del_route.call_count)
# Test no next hope and ensure we delete them all
- with patch(
- f"{BASE_MODULE}.LinuxFib.get_route_table",
- fibs_tests_fixtures.mocked_get_route_table,
- ), patch(
- f"{BASE_MODULE}.LinuxFib.del_route", return_value=True
- ) as mock_del_route:
+ with (
+ patch(
+ f"{BASE_MODULE}.LinuxFib.get_route_table",
+ fibs_tests_fixtures.mocked_get_route_table,
+ ),
+ patch(
+ f"{BASE_MODULE}.LinuxFib.del_route", return_value=True
+ ) as mock_del_route,
+ ):
self.assertTrue(
self.loop.run_until_complete(self.lfib.del_all_routes(None))
)
# 2 prefix/route from v4 and 1 from v6 table
self.assertEqual(3, mock_del_route.call_count) |
JelleZijlstra
approved these changes
Jan 20, 2023
Collaborator
|
Thank you as always! |
yilei
added a commit
to yilei/black
that referenced
this pull request
Feb 2, 2023
ichard26
pushed a commit
that referenced
this pull request
Feb 5, 2023
copybara-service Bot
pushed a commit
to google/pyink
that referenced
this pull request
Feb 6, 2023
Noticeable style changes: 1. Parenthesize multiple context managers psf#3489. The following style changes are temporarily disabled when `--preview` is used together with `--pyink`: 2. Format unicode escape sequences psf#2916. 3. Parenthesize conditional expressions psf#2278. PiperOrigin-RevId: 507485670
This was referenced Mar 1, 2023
28 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #3486.
This also fixes the target version detection logic for parenthesized context managers (3.9) and match statements (3.10). But as far as I can tell, this didn't have user visible impact (until this PR).
I added a dedicated test data folder
preview_context_managers, because this relies on the version detection logic when--target-versionis not explicitly specified.Checklist - did you ...
CHANGES.mdif necessary?