Add docstrings to SequenceDataAbstractBaseClass magic methods by LuciPengu · Pull Request #5240 · biopython/biopython · GitHub
Skip to content

Add docstrings to SequenceDataAbstractBaseClass magic methods#5240

Open
LuciPengu wants to merge 2 commits into
biopython:masterfrom
LuciPengu:add-magic-method-docstrings-seq
Open

Add docstrings to SequenceDataAbstractBaseClass magic methods#5240
LuciPengu wants to merge 2 commits into
biopython:masterfrom
LuciPengu:add-magic-method-docstrings-seq

Conversation

@LuciPengu

@LuciPengu LuciPengu commented Jun 19, 2026

Copy link
Copy Markdown
  • I hereby agree to dual licence this and any previous contributions under both
    the Biopython License Agreement AND the BSD 3-Clause License.

  • I have read the CONTRIBUTING.rst file, have run the style checks
    locally, and understand that continuous integration checks will be used to
    confirm the Biopython unit tests and style checks pass with these changes.

  • I have added my name to the alphabetical contributors listings in the files
    NEWS.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

This is a first batch towards #2116 (ruff D105, "Missing docstring in magic method").

It adds one-line docstrings to the 13 magic methods of
SequenceDataAbstractBaseClass in Bio/Seq.py, following the existing
imperative docstring style used elsewhere in that file. Running
ruff check Bio/Seq.py --select=D105 now reports no violations.

No behaviour is changed. The D105 entry is intentionally left in the ruff
ignore list in .pre-commit-config.yaml, since other modules still contain
undocumented magic methods; that ignore can be removed in a later PR once
they are all documented.

Towards #2116

Add missing one-line docstrings to the 13 magic methods of
SequenceDataAbstractBaseClass in Bio/Seq.py, which previously triggered
ruff's D105 "Missing docstring in magic method" check.

First batch towards issue biopython#2116. The D105 entry in the ruff ignore list
in .pre-commit-config.yaml is left in place for now, since other modules
still contain undocumented magic methods.
Comment thread Bio/Seq.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That suggests to me the return is bytes (but it is a sequence object), does any alternative wording come to mind?

Comment thread Bio/Seq.py
# by _PartiallyDefinedSequenceData.__radd__

def __radd__(self, other):
"""Return the concatenation of other and the sequence data as bytes."""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't think something along the lines of 'add on the right' is relevant here - or following the Python string more closely?

Comment thread Bio/Seq.py
return bytes(self) >= other

def __add__(self, other):
"""Return the concatenation of the sequence data and other as bytes."""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think something modelled after the Python string's docstring would be nicer.

@peterjc

peterjc commented Jun 19, 2026

Copy link
Copy Markdown
Member

Hi Neal, thank you for looking at this. I hope this question is just a formality, but is any of this AI generated? See ongoing discussion starting here: https://mailman.open-bio.org/pipermail/biopython/2026-April/017113.html

@LuciPengu

Copy link
Copy Markdown
Author

Hi Neal, thank you for looking at this. I hope this question is just a formality, but is any of this AI generated? See ongoing discussion starting here: https://mailman.open-bio.org/pipermail/biopython/2026-April/017113.html

I'm so sorry, I had no idea that generative AI wasn't allowed to be used in PRs, I used AI to help me understand the problem and I told it exactly what changes to do to the files as well as to help improve the markdown on my PR but nothing more than that

@peterjc

peterjc commented Jun 22, 2026

Copy link
Copy Markdown
Member

It isn't official policy yet, but it might well be shortly - see #5241. Until that's settled we're not merging any AI PRs (and potentially will have to just close those currently waiting in limbo).

@peterjc

peterjc commented Jun 22, 2026

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants