Skip to content
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

Add typehints_rtype_after_returns option #487

Closed
wants to merge 1 commit into from

Conversation

Kevin-Roberts
Copy link

  • Allow the user to specify the order of the rtype/returns statements.
  • Fix an index error exception caused when always_document_param_types is True and typehints_defaults is 'braces-after'.

* Allow the user to specify the order of the rtype/returns
  statements.
* Fix an index error exception caused when
  always_document_param_types is True and typehints_defaults
  is 'braces-after'.
@Kevin-Roberts
Copy link
Author

Kevin-Roberts commented Sep 20, 2024

So the bug is easy to recreate, just set always_document_param_types=True, typehints_document_rtype=True, typehints_use_rtype=True, typehints_defaults='before-after' (this parameter that ends with *-after is what causes the bug to show up, my fix kind of should fix all index errors via the append() call, may be better ways to fix it) and have a function with a simple docstring with a description and nothing else, for example:

def my_test(variable_1: str) -> str:
   """ 
   bla bla
   """

Also, for the added configuration option to swap the order of rtype and returns, I think it helps people maintain compatibility with how they previously wrote their docstrings (with :rtype:)

@gaborbernat gaborbernat marked this pull request as draft September 20, 2024 15:12
Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

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

Please notify me when the CI passes and you have added tests.

@Kevin-Roberts
Copy link
Author

Sounds good.. You see what I am going for though right

@hoodmane
Copy link
Collaborator

Can you explain why a user would care about this setting? What difference does it make in the rendered output?

@Kevin-Roberts
Copy link
Author

Well so I'm trying to use this plugin for a fairly large project and right now we always have :rtype: after :returns: and I'm trying to avoid having every functions rendered output change (mostly due to automated emails).

Then there is also the bug fix when combining current config options which 100% should be fixed.

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.

3 participants