sameer727 opened a new pull request, #55728:
URL: https://github.com/apache/arrow/pull/55728
### Rationale for this change
The numpydoc validation run (`archery numpydoc --allow-rule
GL10,PR01,PR03,PR04,PR05,PR10,RT03,YD01` in the `conda-python-docs` job) never
reports PR02 (Unknown parameters), so parameters that are documented in a
docstring but absent from the actual signature go unnoticed (#51260).
Additionally, the PR02/PR03 comparison only happens when numpydoc can
introspect the signature, which for cython generated callables depends on
archery parsing the signature from the first docstring line — a step that
currently fails for several objects and silently disables the parameter checks
for them.
### What changes are included in this PR?
1. **archery signature parsing (`dev/archery/archery/lang/python.py`)**:
- skip parameter annotations (not supported by CPython's
`_signature_fromstr`), e.g. `retry_strategy: S3RetryStrategy =
AwsStandardS3RetryStrategy(max_attempts=3)` in `S3FileSystem`;
- drop a trailing bare keyword-only marker, e.g.
`LocalFileSystem(use_mmap=False, *)`;
- when parsing still fails because a default value is not a constant
expression, retry without the default values — the parameter names, kinds and
order are what matter for the docstring validation;
- when the signature cannot be determined at all (e.g. docstrings without
an embedded signature line like `ParquetEncryptionConfig`), skip the
PR01/PR02/PR03 rules instead of comparing the documented parameters against an
empty signature, which would report every documented parameter as unknown.
2. **`python/pyarrow/parquet/core.py`**: `ParquetWriter` documents
`coerce_timestamps`, `allow_truncated_timestamps` and `data_page_size`, but
they were only accepted via `**options`; they are now explicit parameters,
matching `write_table`. `read_pandas` reused the `read_table` docstring
template and documented all of `read_table`'s `**kwargs` options as if they
were its own parameters; it now has a docstring for its own parameters,
pointing to `read_table` for the rest.
3. **`python/pyarrow/_s3fs.pyx`**: reorder the `S3FileSystem` docstring
parameters to match the `__init__` signature order (PR03).
4. **`compose.yaml`**: enable PR02 in the validation run.
### Are these changes tested?
- New unit tests for the parsing in
`dev/archery/archery/tests/test_numpydoc.py` (9 tests, run locally).
- The full validation was run locally with `archery numpydoc --allow-rule
GL10,PR01,PR02,PR03,PR04,PR05,PR10,RT03,YD01` against an installed pyarrow
24.0.0 wheel whose pure-Python modules were overlaid with this PR's versions:
PR02 violations go from 6 objects to 0.
(`ParquetEncryptionConfig`/`ParquetDecryptionConfig`/`OSFile` use the new
skip-when-undeterminable behavior; `S3FileSystem`/`LocalFileSystem` parse after
the parser fixes; `read_pandas`/`ParquetWriter` are fixed in this PR. The
remaining locally-reported PR03 items are pre-existing allowed-rule noise: one
comes from the pyarrow 24 wheel's baked-in `S3FileSystem` docstring, which this
PR reorders in `_s3fs.pyx` for main, and one from `ParquetWriter`, whose
docstring order differs from the signature — same as for `write_table`.)
- The changed `ParquetWriter` parameters were verified functionally by
writing Parquet files with `coerce_timestamps='ms'`,
`allow_truncated_timestamps`, `data_page_size`, the legacy `**options` path
(`metadata_collector`) and no arguments, and reading the metadata back.
### Are there any user-facing changes?
- `ParquetWriter` accepts `coerce_timestamps`, `allow_truncated_timestamps`
and `data_page_size` as explicit keyword arguments (they previously worked via
`**options`).
- `read_pandas`' rendered docstring now documents its own parameters; the
available options are documented in `read_table`, to which `**kwargs` are
passed.
- Docstrings with parameters that don't exist in the signature will now be
reported by the numpydoc CI job.
### Was AI used for this PR?
In accordance to the [AI generation
guidelines](https://arrow.apache.org/docs/dev/developers/overview.html#ai-generated-code),
please disclose below whether and how AI was used in this PR.
**PR code and description written by:**
- [ ] Human
- [x] AI
**Reviewed before submission by:**
- [ ] Human
- [x] AI
- [ ] Not reviewed
This PR was prepared with an AI coding agent (ZCode) at the direction of the
submitter. The root causes were identified by running the archery numpydoc
validation locally against an installed pyarrow wheel (reproducing the
violations from the issue), and every change was verified locally: the parser
fixes by unit tests and by parsing the real objects (`S3FileSystem`,
`LocalFileSystem`), the `ParquetWriter` change by writing/reading files with
the affected parameters, and the overall effect by the validation run going
from 6 PR02 violations to 0.
* GitHub Issue: #51260
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]