Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Generate a dictionary with docstrings for slots that are@cached_propertys#1516

Draft
clayote wants to merge 6 commits intopython-attrs:mainfrom
clayote:cache_prop_slots_doc
Draft

Generate a dictionary with docstrings for slots that are@cached_propertys#1516
clayote wants to merge 6 commits intopython-attrs:mainfrom
clayote:cache_prop_slots_doc

Conversation

@clayote
Copy link

Summary

I couldn't get Sphinx to generate docstrings for@cached_propertys on attrs' defaultslots=True classes. Trying to replace the generated__getattr__ didn't perform so well...but,__slots__ can be a dictionary, and that dictionary can have docstrings in it. This PR makes attrs generate__slots__ as a dictionary, with docstrings copied from the decorated@cached_property functions.

I haven't worked out how to make Sphinx render these like@property. Might be doable.

Pull Request Check List

  • Donot open pull requests from yourmain branch –use a separate branch!
    • There's a ton of footguns waiting if you don't heed this warning. You can still go back to your project, create a branch from your main branch, push it, and open the pull request from the new branch.
    • This is not a pre-requisite for your pull request to be accepted, butyou have been warned.
  • Addedtests for changed code.
    Our CI fails if coverage is not 100%.
  • Changes or additions to public APIs are reflected in our type stubs (files ending in.pyi).
    • ...and used in the stub test filetyping-examples/baseline.py or, if necessary,typing-examples/mypy.py.
    • If they've been added toattr/__init__.pyi, they'vealso been re-imported inattrs/__init__.pyi.
  • Updateddocumentation for changed code.
    • New functions/classes have to be added todocs/api.rst by hand.
    • Changes to the signatures of@attr.s() and@attrs.define() have to be added by hand too.
    • Changed/added classes/methods/functions have appropriateversionadded,versionchanged, ordeprecateddirectives.
      The next version is the second number in the current release + 1.
      The first number represents the current year.
      So if the current version on PyPI is 22.2.0, the next version is gonna be 22.3.0.
      If the next version is the first in the new year, it'll be 23.1.0.
      • If something changed that affects bothattrs.define() andattr.s(), you have to add version directives to both.
  • Documentation in.rst and.md files is written usingsemantic newlines.
  • Changes (and possible deprecations) have news fragments inchangelog.d.
  • Consider grantingpush permissions to the PR branch, so maintainers can fix minor issues themselves without pestering you.

I have not worked out how to make the annotation really show up in generated Sphinx output. At least the docstring is there.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@clayote

Comments


[8]ページ先頭

©2009-2026 Movatter.jp