Skip to content

Commit 99c6116

Browse files
authored
Removed unnecessary dict calls (#38319)
1 parent 1db3aa2 commit 99c6116

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

pandas/tests/io/parser/test_quoting.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
@pytest.mark.parametrize(
1818
"kwargs,msg",
1919
[
20-
(dict(quotechar="foo"), '"quotechar" must be a(n)? 1-character string'),
20+
({"quotechar": "foo"}, '"quotechar" must be a(n)? 1-character string'),
2121
(
22-
dict(quotechar=None, quoting=csv.QUOTE_MINIMAL),
22+
{"quotechar": None, "quoting": csv.QUOTE_MINIMAL},
2323
"quotechar must be set if quoting enabled",
2424
),
25-
(dict(quotechar=2), '"quotechar" must be string, not int'),
25+
({"quotechar": 2}, '"quotechar" must be string, not int'),
2626
],
2727
)
2828
def test_bad_quote_char(all_parsers, kwargs, msg):
@@ -72,7 +72,7 @@ def test_quote_char_various(all_parsers, quote_char):
7272
@pytest.mark.parametrize("quoting", [csv.QUOTE_MINIMAL, csv.QUOTE_NONE])
7373
@pytest.mark.parametrize("quote_char", ["", None])
7474
def test_null_quote_char(all_parsers, quoting, quote_char):
75-
kwargs = dict(quotechar=quote_char, quoting=quoting)
75+
kwargs = {"quotechar": quote_char, "quoting": quoting}
7676
data = "a,b,c\n1,2,3"
7777
parser = all_parsers
7878

@@ -91,17 +91,17 @@ def test_null_quote_char(all_parsers, quoting, quote_char):
9191
@pytest.mark.parametrize(
9292
"kwargs,exp_data",
9393
[
94-
(dict(), [[1, 2, "foo"]]), # Test default.
94+
({}, [[1, 2, "foo"]]), # Test default.
9595
# QUOTE_MINIMAL only applies to CSV writing, so no effect on reading.
96-
(dict(quotechar='"', quoting=csv.QUOTE_MINIMAL), [[1, 2, "foo"]]),
96+
({"quotechar": '"', "quoting": csv.QUOTE_MINIMAL}, [[1, 2, "foo"]]),
9797
# QUOTE_MINIMAL only applies to CSV writing, so no effect on reading.
98-
(dict(quotechar='"', quoting=csv.QUOTE_ALL), [[1, 2, "foo"]]),
98+
({"quotechar": '"', "quoting": csv.QUOTE_ALL}, [[1, 2, "foo"]]),
9999
# QUOTE_NONE tells the reader to do no special handling
100100
# of quote characters and leave them alone.
101-
(dict(quotechar='"', quoting=csv.QUOTE_NONE), [[1, 2, '"foo"']]),
101+
({"quotechar": '"', "quoting": csv.QUOTE_NONE}, [[1, 2, '"foo"']]),
102102
# QUOTE_NONNUMERIC tells the reader to cast
103103
# all non-quoted fields to float
104-
(dict(quotechar='"', quoting=csv.QUOTE_NONNUMERIC), [[1.0, 2.0, "foo"]]),
104+
({"quotechar": '"', "quoting": csv.QUOTE_NONNUMERIC}, [[1.0, 2.0, "foo"]]),
105105
],
106106
)
107107
def test_quoting_various(all_parsers, kwargs, exp_data):

pandas/tests/io/parser/test_usecols.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,14 @@ def test_incomplete_first_row(all_parsers, usecols):
477477
(
478478
"19,29,39\n" * 2 + "10,20,30,40",
479479
[0, 1, 2],
480-
dict(header=None),
480+
{"header": None},
481481
DataFrame([[19, 29, 39], [19, 29, 39], [10, 20, 30]]),
482482
),
483483
# see gh-9549
484484
(
485485
("A,B,C\n1,2,3\n3,4,5\n1,2,4,5,1,6\n1,2,3,,,1,\n1,2,3\n5,6,7"),
486486
["A", "B", "C"],
487-
dict(),
487+
{},
488488
DataFrame(
489489
{
490490
"A": [1, 3, 1, 1, 1, 5],
@@ -507,39 +507,39 @@ def test_uneven_length_cols(all_parsers, data, usecols, kwargs, expected):
507507
[
508508
(
509509
["a", "b", "c", "d"],
510-
dict(),
510+
{},
511511
DataFrame({"a": [1, 5], "b": [2, 6], "c": [3, 7], "d": [4, 8]}),
512512
None,
513513
),
514514
(
515515
["a", "b", "c", "f"],
516-
dict(),
516+
{},
517517
None,
518518
_msg_validate_usecols_names.format(r"\['f'\]"),
519519
),
520-
(["a", "b", "f"], dict(), None, _msg_validate_usecols_names.format(r"\['f'\]")),
520+
(["a", "b", "f"], {}, None, _msg_validate_usecols_names.format(r"\['f'\]")),
521521
(
522522
["a", "b", "f", "g"],
523-
dict(),
523+
{},
524524
None,
525525
_msg_validate_usecols_names.format(r"\[('f', 'g'|'g', 'f')\]"),
526526
),
527527
# see gh-14671
528528
(
529529
None,
530-
dict(header=0, names=["A", "B", "C", "D"]),
530+
{"header": 0, "names": ["A", "B", "C", "D"]},
531531
DataFrame({"A": [1, 5], "B": [2, 6], "C": [3, 7], "D": [4, 8]}),
532532
None,
533533
),
534534
(
535535
["A", "B", "C", "f"],
536-
dict(header=0, names=["A", "B", "C", "D"]),
536+
{"header": 0, "names": ["A", "B", "C", "D"]},
537537
None,
538538
_msg_validate_usecols_names.format(r"\['f'\]"),
539539
),
540540
(
541541
["A", "B", "f"],
542-
dict(names=["A", "B", "C", "D"]),
542+
{"names": ["A", "B", "C", "D"]},
543543
None,
544544
_msg_validate_usecols_names.format(r"\['f'\]"),
545545
),

0 commit comments

Comments
 (0)