Skip to content

Commit aaac9b8

Browse files
jordan-d-murphypmhatre1
authored andcommitted
DOC: fix EX03 errors in docstrings - pandas.Series.plot.line, pandas.Series.to_sql, pandas.read_json, pandas.DataFrame.to_sql (pandas-dev#57025)
* DOC: fix EX03 errors in docstrings - pandas.Series.plot.line, pandas.Series.to_sql, pandas.read_json, pandas.DataFrame.to_sql * removed EX03 specific block, and added EX03 to "Validate docstrings" block
1 parent 12566a7 commit aaac9b8

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

ci/code_checks.sh

+2-10
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,8 @@ fi
6565
### DOCSTRINGS ###
6666
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
6767

68-
MSG='Validate docstrings (EX01, EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT02, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
69-
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01,EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT02,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
70-
RET=$(($RET + $?)) ; echo $MSG "DONE"
71-
72-
MSG='Partially validate docstrings (EX03)' ; echo $MSG
73-
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX03 --ignore_functions \
74-
pandas.Series.plot.line \
75-
pandas.Series.to_sql \
76-
pandas.read_json \
77-
pandas.DataFrame.to_sql # There should be no backslash in the final line, please keep this comment in the last ignored function
68+
MSG='Validate docstrings (EX01, EX03, EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT02, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
69+
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01,EX03,EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT02,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
7870
RET=$(($RET + $?)) ; echo $MSG "DONE"
7971

8072
MSG='Partially validate docstrings (PR02)' ; echo $MSG

pandas/core/generic.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -2999,7 +2999,7 @@ def to_sql(
29992999
3
30003000
>>> from sqlalchemy import text
30013001
>>> with engine.connect() as conn:
3002-
... conn.execute(text("SELECT * FROM users")).fetchall()
3002+
... conn.execute(text("SELECT * FROM users")).fetchall()
30033003
[(0, 'User 1'), (1, 'User 2'), (2, 'User 3')]
30043004
30053005
An `sqlalchemy.engine.Connection` can also be passed to `con`:
@@ -3016,7 +3016,7 @@ def to_sql(
30163016
>>> df2.to_sql(name='users', con=engine, if_exists='append')
30173017
2
30183018
>>> with engine.connect() as conn:
3019-
... conn.execute(text("SELECT * FROM users")).fetchall()
3019+
... conn.execute(text("SELECT * FROM users")).fetchall()
30203020
[(0, 'User 1'), (1, 'User 2'), (2, 'User 3'),
30213021
(0, 'User 4'), (1, 'User 5'), (0, 'User 6'),
30223022
(1, 'User 7')]
@@ -3027,7 +3027,7 @@ def to_sql(
30273027
... index_label='id')
30283028
2
30293029
>>> with engine.connect() as conn:
3030-
... conn.execute(text("SELECT * FROM users")).fetchall()
3030+
... conn.execute(text("SELECT * FROM users")).fetchall()
30313031
[(0, 'User 6'), (1, 'User 7')]
30323032
30333033
Use ``method`` to define a callable insertion method to do nothing
@@ -3040,13 +3040,14 @@ def to_sql(
30403040
... stmt = insert(table.table).values(data).on_conflict_do_nothing(index_elements=["a"])
30413041
... result = conn.execute(stmt)
30423042
... return result.rowcount
3043-
>>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", method=insert_on_conflict_nothing) # doctest: +SKIP
3043+
>>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", # noqa: F821
3044+
... method=insert_on_conflict_nothing) # doctest: +SKIP
30443045
0
30453046
30463047
For MySQL, a callable to update columns ``b`` and ``c`` if there's a conflict
30473048
on a primary key.
30483049
3049-
>>> from sqlalchemy.dialects.mysql import insert
3050+
>>> from sqlalchemy.dialects.mysql import insert # noqa: F811
30503051
>>> def insert_on_conflict_update(table, conn, keys, data_iter):
30513052
... # update columns "b" and "c" on primary key conflict
30523053
... data = [dict(zip(keys, row)) for row in data_iter]
@@ -3057,7 +3058,8 @@ def to_sql(
30573058
... stmt = stmt.on_duplicate_key_update(b=stmt.inserted.b, c=stmt.inserted.c)
30583059
... result = conn.execute(stmt)
30593060
... return result.rowcount
3060-
>>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", method=insert_on_conflict_update) # doctest: +SKIP
3061+
>>> df_conflict.to_sql(name="conflict_table", con=conn, if_exists="append", # noqa: F821
3062+
... method=insert_on_conflict_update) # doctest: +SKIP
30613063
2
30623064
30633065
Specify the dtype (especially useful for integers with missing values).
@@ -3078,7 +3080,7 @@ def to_sql(
30783080
3
30793081
30803082
>>> with engine.connect() as conn:
3081-
... conn.execute(text("SELECT * FROM integers")).fetchall()
3083+
... conn.execute(text("SELECT * FROM integers")).fetchall()
30823084
[(1,), (None,), (2,)]
30833085
""" # noqa: E501
30843086
from pandas.io import sql

pandas/io/json/_json.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ def read_json(
717717
"data":[["a","b"],["c","d"]]\
718718
}}\
719719
'
720-
>>> pd.read_json(StringIO(_), orient='split')
720+
>>> pd.read_json(StringIO(_), orient='split') # noqa: F821
721721
col 1 col 2
722722
row 1 a b
723723
row 2 c d
@@ -727,7 +727,7 @@ def read_json(
727727
>>> df.to_json(orient='index')
728728
'{{"row 1":{{"col 1":"a","col 2":"b"}},"row 2":{{"col 1":"c","col 2":"d"}}}}'
729729
730-
>>> pd.read_json(StringIO(_), orient='index')
730+
>>> pd.read_json(StringIO(_), orient='index') # noqa: F821
731731
col 1 col 2
732732
row 1 a b
733733
row 2 c d
@@ -737,7 +737,7 @@ def read_json(
737737
738738
>>> df.to_json(orient='records')
739739
'[{{"col 1":"a","col 2":"b"}},{{"col 1":"c","col 2":"d"}}]'
740-
>>> pd.read_json(StringIO(_), orient='records')
740+
>>> pd.read_json(StringIO(_), orient='records') # noqa: F821
741741
col 1 col 2
742742
0 a b
743743
1 c d

0 commit comments

Comments
 (0)