From 03e29b1542ed6480352f1411eede5ef25600cc40 Mon Sep 17 00:00:00 2001 From: Compro-Prasad Date: Sat, 29 Jan 2022 23:04:11 +0530 Subject: [PATCH] Simplify conditional branch in _read function in readers.py --- pandas/io/parsers/readers.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pandas/io/parsers/readers.py b/pandas/io/parsers/readers.py index ef693fcbd3720..5f93eef4fd977 100644 --- a/pandas/io/parsers/readers.py +++ b/pandas/io/parsers/readers.py @@ -542,13 +542,11 @@ def _read( """Generic reader of line files.""" # if we pass a date_parser and parse_dates=False, we should not parse the # dates GH#44366 - if ( - kwds.get("date_parser", None) is not None - and kwds.get("parse_dates", None) is None - ): - kwds["parse_dates"] = True - elif kwds.get("parse_dates", None) is None: - kwds["parse_dates"] = False + if kwds.get("parse_dates", None) is None: + if kwds.get("date_parser", None) is None: + kwds["parse_dates"] = False + else: + kwds["parse_dates"] = True # Extract some of the arguments (pass chunksize on). iterator = kwds.get("iterator", False) @@ -564,7 +562,7 @@ def _read( "The 'chunksize' option is not supported with the 'pyarrow' engine" ) else: - chunksize = validate_integer("chunksize", kwds.get("chunksize", None), 1) + chunksize = validate_integer("chunksize", chunksize, 1) nrows = kwds.get("nrows", None)