Giter Site home page Giter Site logo

Comments (17)

Viech avatar Viech commented on July 3, 2024 3

I think this issue should be reopened as #235 does not seem to affect the general case where a method decorated with @property is requried to be in imperative mood. So while Alias might be treated as a potential imperative now, properties are still not allowed a docstring starting with words like The or A.

from pydocstyle.

jacebrowning avatar jacebrowning commented on July 3, 2024 2

I have found this rule useful, but perhaps it should not apply to properties. All other method docstrings should be imperative (and I can't really think of any false positives), but property docstrings are typically not going to be imperative unless you do something like "Get the value of...".

from pydocstyle.

sigmavirus24 avatar sigmavirus24 commented on July 3, 2024 2

A whitelist would be unmaintainable in my opinion @jacebrowning

from pydocstyle.

josauder avatar josauder commented on July 3, 2024 2

Large neural network language models such as GPT-3 open up completely new possibilities to check if a sentence is in imperative mode. Maybe this should be added to this project.

I don think this would impair productivity even more than attempting to check if docstrings are in imperative to begin with.
@bjrne

from pydocstyle.

lukelbd avatar lukelbd commented on July 3, 2024 2

I'd also support reopening this. Imperative mood checking is a very promising feature but enforcing it for @property "functions" forces me to ignore all D401 errors.

from pydocstyle.

jacebrowning avatar jacebrowning commented on July 3, 2024 1

I found another good example of a false positive: """Focus the application."""

Perhaps pep257 could have a list of acceptable words that end in s?

from pydocstyle.

merwok avatar merwok commented on July 3, 2024 1

You donโ€™t write docstring for them :)

from pydocstyle.

sigmavirus24 avatar sigmavirus24 commented on July 3, 2024

Actually, this might read better as """An alias for consistency with the rest of pocketlint."""

from pydocstyle.

glennmatthews avatar glennmatthews commented on July 3, 2024

It could be interesting to investigate using NLTK (http://www.nltk.org/) here, although that would almost certainly be massive overkill.

from pydocstyle.

Nurdok avatar Nurdok commented on July 3, 2024

I asked about this in English StackExchange: http://english.stackexchange.com/questions/216043/telling-if-a-word-is-a-verb-in-the-imperative-mood

from pydocstyle.

lordmauve avatar lordmauve commented on July 3, 2024

This could be fixed by listing imperative forms of verbs and comparing with, say, a Porter stemmer (assuming English).

If the stemmed form of the word is in the stemmed list of verbs, then it's probably a verb. But if the unstemmed form is not in the unstemmed list, it's not in the imperative form.

This would have a much lower false positive rate than the current heuristic, but a somewhat larger false negative rate, depending on the size of the word list. But I'm guessing that relatively small lists of verbs would cover a high percentage of docstrings, due to the constrained nature of the language used (outside of domain-specific jargon).

We could generate a reasonably good word list by scanning docstrings of a few largish Python projects and manually removing words that are not imperative verbs.

from pydocstyle.

lordmauve avatar lordmauve commented on July 3, 2024

Also it's out of scope to do a full grammar analysis, so we could never detect imperative or not in a docstring like

def median(xs):
    """Given a list of numbers xs, return the median."""

We could only flag up words that are verbs but not in an imperative form.

from pydocstyle.

lordmauve avatar lordmauve commented on July 3, 2024

I started scanning my codebase for the verbs we use here. We could also add a blacklist approach - there are words that are very much indicators of non-imperative docstrings.

from pydocstyle.

lordmauve avatar lordmauve commented on July 3, 2024

Can this issue be closed, now #235 is merged?

from pydocstyle.

GameDungeon avatar GameDungeon commented on July 3, 2024

I would too. Or at least allow "The" or "A" for them.

from pydocstyle.

lordmauve avatar lordmauve commented on July 3, 2024

Please open a new issue if you think D401 should not apply to @property functions*. That is not the issue that was addressed here.

* But I would argue it should because if you allow a noun phrase for the getter what do you write in the docstring for a setter or a deleter?

from pydocstyle.

lukelbd avatar lukelbd commented on July 3, 2024

I've started a new thread: #566.

from pydocstyle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.