Skip to content

CLN: Remove unicode u string prefix in regexes #26433

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

Merged
merged 2 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ def test_omit_nuisance(df):
grouped = df.groupby({'A': 0, 'C': 0, 'D': 1, 'E': 1}, axis=1)
msg = (r'\("unsupported operand type\(s\) for \+: '
"'Timestamp' and 'float'\""
r", u?'occurred at index 0'\)")
r", 'occurred at index 0'\)")
with pytest.raises(TypeError, match=msg):
grouped.agg(lambda x: x.sum(0, numeric_only=False))

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def test_from_freq_recreate_from_data(self, freq):

def test_datetimeindex_constructor_misc(self):
arr = ['1/1/2005', '1/2/2005', 'Jn 3, 2005', '2005-01-04']
msg = r"(\(u?')?Unknown string format(:', 'Jn 3, 2005'\))?"
msg = r"(\(')?Unknown string format(:', 'Jn 3, 2005'\))?"
with pytest.raises(ValueError, match=msg):
DatetimeIndex(arr)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ def test_to_datetime_on_datetime64_series(self, cache):
def test_to_datetime_with_space_in_series(self, cache):
# GH 6428
s = Series(['10/18/2006', '10/18/2008', ' '])
msg = r"(\(u?')?String does not contain a date(:', ' '\))?"
msg = r"(\(')?String does not contain a date(:', ' '\))?"
with pytest.raises(ValueError, match=msg):
to_datetime(s, errors='raise', cache=cache)
result_coerce = to_datetime(s, errors='coerce', cache=cache)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def test_loc_to_fail(self):
with pytest.raises(KeyError, match=msg):
s.loc[[-1, -2]]

msg = (r"\"None of \[Index\(\[u?'4'\], dtype='object'\)\] are"
msg = (r"\"None of \[Index\(\['4'\], dtype='object'\)\] are"
r" in the \[index\]\"")
with pytest.raises(KeyError, match=msg):
s.loc[['4']]
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexing/test_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def test_series_partial_set_with_name(self):

# raises as nothing in in the index
msg = (r"\"None of \[Int64Index\(\[3, 3, 3\], dtype='int64',"
r" name=u?'idx'\)\] are in the \[index\]\"")
r" name='idx'\)\] are in the \[index\]\"")
with pytest.raises(KeyError, match=msg):
ser.loc[[3, 3, 3]]

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ def test_misc_example(self):
error_msg = """DataFrame\\.index are different
DataFrame\\.index values are different \\(100\\.0 %\\)
\\[left\\]: Index\\(\\[u?'a', u?'b'\\], dtype='object'\\)
\\[left\\]: Index\\(\\['a', 'b'\\], dtype='object'\\)
\\[right\\]: RangeIndex\\(start=0, stop=2, step=1\\)"""
with pytest.raises(AssertionError, match=error_msg):
assert_frame_equal(result, expected, check_index_type=False)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/msgpack/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def testStrictUnicodeUnpack(self):
unpackb(packb(b'abc\xeddef'), encoding='utf-8', use_list=1)

def testStrictUnicodePack(self):
msg = (r"'ascii' codec can't encode character u*'\\xed' in position 3:"
msg = (r"'ascii' codec can't encode character '\\xed' in position 3:"
r" ordinal not in range\(128\)")
with pytest.raises(UnicodeEncodeError, match=msg):
packb("abc\xeddef", encoding='ascii', unicode_errors='strict')
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/reshape/merge/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def test_overlapping_columns_error_message(self):

# #2649, #10639
df2.columns = ['key1', 'foo', 'foo']
msg = (r"Data columns not unique: Index\(\[u?'foo', u?'foo'\],"
msg = (r"Data columns not unique: Index\(\['foo', 'foo'\],"
r" dtype='object'\)")
with pytest.raises(MergeError, match=msg):
merge(df, df2)
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/util/test_assert_frame_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ def test_frame_equal_index_mismatch():
msg = """DataFrame\\.index are different
DataFrame\\.index values are different \\(33\\.33333 %\\)
\\[left\\]: Index\\(\\[u?'a', u?'b', u?'c'\\], dtype='object'\\)
\\[right\\]: Index\\(\\[u?'a', u?'b', u?'d'\\], dtype='object'\\)"""
\\[left\\]: Index\\(\\['a', 'b', 'c'\\], dtype='object'\\)
\\[right\\]: Index\\(\\['a', 'b', 'd'\\], dtype='object'\\)"""

df1 = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]},
index=["a", "b", "c"])
Expand All @@ -156,8 +156,8 @@ def test_frame_equal_columns_mismatch():
msg = """DataFrame\\.columns are different
DataFrame\\.columns values are different \\(50\\.0 %\\)
\\[left\\]: Index\\(\\[u?'A', u?'B'\\], dtype='object'\\)
\\[right\\]: Index\\(\\[u?'A', u?'b'\\], dtype='object'\\)"""
\\[left\\]: Index\\(\\['A', 'B'\\], dtype='object'\\)
\\[right\\]: Index\\(\\['A', 'b'\\], dtype='object'\\)"""

df1 = DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]},
index=["a", "b", "c"])
Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/util/test_assert_index_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_index_equal_levels_mismatch():
Index levels are different
\\[left\\]: 1, Int64Index\\(\\[1, 2, 3\\], dtype='int64'\\)
\\[right\\]: 2, MultiIndex\\(levels=\\[\\[u?'A', u?'B'\\], \\[1, 2, 3, 4\\]\\],
\\[right\\]: 2, MultiIndex\\(levels=\\[\\['A', 'B'\\], \\[1, 2, 3, 4\\]\\],
codes=\\[\\[0, 0, 1, 1\\], \\[0, 1, 2, 3\\]\\]\\)"""

idx1 = Index([1, 2, 3])
Expand Down Expand Up @@ -151,8 +151,8 @@ def test_index_equal_names(name1, name2):
if name1 == name2 or name1 is name2:
assert_index_equal(idx1, idx2)
else:
name1 = "u?'x'" if name1 == "x" else name1
name2 = "u?'x'" if name2 == "x" else name2
name1 = "'x'" if name1 == "x" else name1
name2 = "'x'" if name2 == "x" else name2
msg = msg.format(name1=name1, name2=name2)

with pytest.raises(AssertionError, match=msg):
Expand All @@ -163,8 +163,8 @@ def test_index_equal_category_mismatch(check_categorical):
msg = """Index are different
Attribute "dtype" are different
\\[left\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b'\\], ordered=False\\)
\\[right\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b', u?'c'\\], \
\\[left\\]: CategoricalDtype\\(categories=\\['a', 'b'\\], ordered=False\\)
\\[right\\]: CategoricalDtype\\(categories=\\['a', 'b', 'c'\\], \
ordered=False\\)"""

idx1 = Index(Categorical(["a", "b"]))
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/util/test_assert_series_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def test_series_equal_categorical_mismatch(check_categorical):
msg = """Attributes are different
Attribute "dtype" are different
\\[left\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b'\\], ordered=False\\)
\\[right\\]: CategoricalDtype\\(categories=\\[u?'a', u?'b', u?'c'\\], \
\\[left\\]: CategoricalDtype\\(categories=\\['a', 'b'\\], ordered=False\\)
\\[right\\]: CategoricalDtype\\(categories=\\['a', 'b', 'c'\\], \
ordered=False\\)"""

s1 = Series(Categorical(["a", "b"]))
Expand Down