Skip to content

Commit ea40e98

Browse files
committed
Fix formatting
1 parent b238935 commit ea40e98

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed

pandas/core/reshape/merge.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ def _validate_left_right_on(self, left_on, right_on):
16241624
@final
16251625
def _validate_validate_kwd(self, validate: str) -> None:
16261626
# Split validation string
1627-
validations = validate.split('+')
1627+
validations = validate.split("+")
16281628

16291629
# Check uniqueness of each
16301630
if self.left_index:
@@ -1654,17 +1654,20 @@ def _validate_validate_kwd(self, validate: str) -> None:
16541654
)
16551655
if not left_unique:
16561656
raise MergeError(
1657-
"Merge keys are not unique in left dataset; not a one-to-one merge"
1657+
"Merge keys are not unique in left dataset; "
1658+
"not a one-to-one merge"
16581659
)
16591660
if not right_unique:
16601661
raise MergeError(
1661-
"Merge keys are not unique in right dataset; not a one-to-one merge"
1662+
"Merge keys are not unique in right dataset; "
1663+
"not a one-to-one merge"
16621664
)
16631665

16641666
elif validation in ["one_to_many", "1:m"]:
16651667
if not left_unique:
16661668
raise MergeError(
1667-
"Merge keys are not unique in left dataset; not a one-to-many merge"
1669+
"Merge keys are not unique in left dataset; "
1670+
"not a one-to-many merge"
16681671
)
16691672

16701673
elif validation in ["many_to_one", "m:1"]:
@@ -1680,33 +1683,33 @@ def _validate_validate_kwd(self, validate: str) -> None:
16801683
elif validation in ["total"]:
16811684
if not left_total and not right_total:
16821685
raise MergeError(
1683-
"Neither the merge keys in the left dataset are all present in "
1684-
"the right dataset, nor the merge keys in the right dataset all "
1685-
"present in the left dataset; not a total merge."
1686+
"Neither the merge keys in the left dataset are all present "
1687+
"in the right dataset, nor the merge keys in the right "
1688+
"dataset all present in the left dataset; not a total merge."
16861689
)
16871690
if not left_total:
16881691
raise MergeError(
1689-
"Merge keys in left dataset are not all present in the right dataset; "
1690-
"not a total merge"
1692+
"Merge keys in left dataset are not all present in the right "
1693+
"dataset; not a total merge"
16911694
)
16921695
if not right_total:
16931696
raise MergeError(
1694-
"Merge keys in right dataset are not all present in the left dataset; "
1695-
"not a total merge"
1697+
"Merge keys in right dataset are not all present "
1698+
"in the left dataset; not a total merge"
16961699
)
16971700

16981701
elif validation in ["left_total"]:
16991702
if not left_total:
17001703
raise MergeError(
1701-
"Merge keys in left dataset are not all present in the right dataset; "
1702-
"not a left total merge"
1704+
"Merge keys in left dataset are not all present "
1705+
"in the right dataset; not a left total merge"
17031706
)
17041707

17051708
elif validation in ["right_total"]:
17061709
if not right_total:
17071710
raise MergeError(
1708-
"Merge keys in right dataset are not all present in the left dataset; "
1709-
"not a right total merge"
1711+
"Merge keys in right dataset are not all present "
1712+
"in the left dataset; not a right total merge"
17101713
)
17111714

17121715
else:

pandas/tests/reshape/merge/test_merge.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,12 +1205,19 @@ def test_validation(self):
12051205

12061206
# Make sure left totality works
12071207
result = merge(
1208-
left, right, left_index=True, right_index=True, validate="one_to_one+left_total"
1208+
left,
1209+
right,
1210+
left_index=True,
1211+
right_index=True,
1212+
validate="one_to_one+left_total",
12091213
)
12101214
tm.assert_frame_equal(result, expected)
12111215

12121216
# Make sure right totality raises exception
1213-
msg = "Merge keys in right dataset are not all present in the left dataset; not a right total merge"
1217+
msg = (
1218+
"Merge keys in right dataset are not all present in the left dataset; "
1219+
"not a right total merge"
1220+
)
12141221
with pytest.raises(MergeError, match=msg):
12151222
merge(
12161223
left,
@@ -1221,7 +1228,10 @@ def test_validation(self):
12211228
)
12221229

12231230
# Make sure general totality raises exception
1224-
msg = "Merge keys in right dataset are not all present in the left dataset; not a total merge"
1231+
msg = (
1232+
"Merge keys in right dataset are not all present in the left dataset; "
1233+
"not a total merge"
1234+
)
12251235
with pytest.raises(MergeError, match=msg):
12261236
merge(
12271237
left,
@@ -1370,7 +1380,8 @@ def test_validation(self):
13701380
tm.assert_frame_equal(result, expected_multi)
13711381

13721382
right_total_ext = concat(
1373-
[right, DataFrame({"a": ["b"], "b": [1], "d": ["neigh"]}, index=[3])], sort=True
1383+
[right, DataFrame({"a": ["b"], "b": [1], "d": ["neigh"]}, index=[3])],
1384+
sort=True,
13741385
)
13751386
expected_total_ext = DataFrame(
13761387
{
@@ -1385,9 +1396,12 @@ def test_validation(self):
13851396
tm.assert_frame_equal(result, expected_total_ext)
13861397

13871398
# Ensure not left total raises error
1388-
right_reduced = right.drop_duplicates(subset=['b'])
1399+
right_reduced = right.drop_duplicates(subset=["b"])
13891400

1390-
msg = "Merge keys in left dataset are not all present in the right dataset; not a left total merge"
1401+
msg = (
1402+
"Merge keys in left dataset are not all present in the right dataset; "
1403+
"not a left total merge"
1404+
)
13911405
with pytest.raises(MergeError, match=msg):
13921406
merge(
13931407
left,

0 commit comments

Comments
 (0)