Skip to content

Navigation Menu

Sign in
Sign up

GH-51260: [Python][Docs][CI] Disabled numpydoc PR02 check may skip PR03 #51261

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

Draft
tadeja wants to merge 3 commits into apache:main
base: main
Choose a base branch
Loading
from tadeja:numpydoc-PR02
Draft
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 compose.yaml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ services:
["/arrow/ci/scripts/cpp_build.sh /arrow /build &&
/arrow/ci/scripts/python_build.sh /arrow /build &&
pip install -e /arrow/dev/archery[numpydoc] &&
archery numpydoc --allow-rule GL10,PR01,PR03,PR04,PR05,PR10,RT03,YD01 &&
archery numpydoc --allow-rule GL10,PR01,PR02,PR03,PR04,PR05,PR10,RT03,YD01 &&
/arrow/ci/scripts/python_test.sh /arrow &&
/arrow/ci/scripts/python_test_type_annotations.sh /arrow/python"]

Expand Down
14 changes: 14 additions & 0 deletions dev/archery/archery/lang/python.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class NumpyDoc:
EnumMeta: ["PR01"]
}

# When there's no signature (like for Cython classes where it can't parse
# __init__), numpydoc sees zero parameters and reports "Unknown parameters"
PARAMETER_CHECKS = ("PR01", "PR02", "PR03")

def __init__(self, symbols=None):
if not have_numpydoc:
raise RuntimeError(
Expand Down Expand Up @@ -203,6 +207,13 @@ def callback(obj):
logger.warning(f"Unable to validate `{symbol}` due to `{e}`")
return

try:
inspect.signature(obj)
except (TypeError, ValueError):
has_signature = False
else:
has_signature = True

errors = []
for errcode, errmsg in result.get('errors', []):
if allow_rules and errcode not in allow_rules:
Expand All @@ -213,6 +224,9 @@ def callback(obj):
for obj_type, errcode_list
in NumpyDoc.IGNORE_VALIDATION_ERRORS_FOR_TYPE.items()):
continue
if (not has_signature and
errcode in NumpyDoc.PARAMETER_CHECKS):
continue
errors.append((errcode, errmsg))

if len(errors):
Expand Down
1 change: 1 addition & 0 deletions python/pyproject.toml
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ test = [
checks = [
"GL10",
"PR01",
"PR02",
"PR03",
"PR04",
"PR05",
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /