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 task-tags & ignore-overlong-task-comments settings #1654

Merged
merged 4 commits into from Jan 5, 2023

Commits on Jan 5, 2023

  1. Copy the full SHA
    3daea3c View commit details
    Browse the repository at this point in the history
  2. Add task-tags setting

    Programmers often leave comments to themselves and others such as:
    
        # TODO: Use a faster algorithm?
    
    The keywords used to prefix such comments are just a convention and vary
    from project to project. Other common keywords include FIXME and HACK.
    
    The keywords in use for the codebase are of interest to ruff because
    ruff does also lint comments. For example the ERA lint detects
    commented-out code but ignores comments starting with such a keyword.
    Previously the ERA lint simply hardcoded the regular expression
    TODO|FIXME|XXX to achieve that. This commit introduces a new `task-tags`
    setting to make this configurable (and to allow other comment lints to
    recognize the same set of keywords).
    
    The term "task tags" has probably been popularized by the Eclipse
    IDE.[1] For Python there has been the proposal PEP 350[2], which
    referred to such keywords as "codetags". That proposal however has been
    rejected. We are choosing the term "task tags" over "code tags" because
    the former is more descriptive: a task tag describes a task.
    
    While according to the PEP 350 such keywords are also sometimes used for
    non-tasks e.g. NOBUG to describe a well-known problem that will never be
    addressed due to design problems or domain limitations, such keywords
    are so rare that we are neglecting them here in favor of more
    descriptive terminology. The vast majority of such keywords does
    describe tasks, so naming the setting "task-tags" is apt.
    
    [1]: https://www.eclipse.org/pdt/help/html/task_tags.htm
    [2]: https://peps.python.org/pep-0350/
    
    Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
    not-my-profile and charliermarsh committed Jan 5, 2023
    Copy the full SHA
    dfd62f3 View commit details
    Browse the repository at this point in the history
  3. Add pycodestyle::settings

    This step is split up into a separate commit so
    that the following commit has a cleaner diff.
    not-my-profile authored and charliermarsh committed Jan 5, 2023
    Copy the full SHA
    9473fd2 View commit details
    Browse the repository at this point in the history
  4. Add ignore-overlong-task-comments setting

    Imagine a .py file containing the following comment:
    
        # TODO: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
        # do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    
    Since `git grep` only matches individual lines `git grep TODO` would
    only output the first line of the comment, cutting off potentially
    important information. (git grep currently doesn't support multiline
    grepping). Projects using such a workflow therefore probably format
    the comment in a single line instead:
    
        # TODO: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    
    This commit introduces a setting to accomdate this workflow by making
    the line-length checks (`E501`) optionally ignore overlong lines
    if they start with a recognized task tag.
    
    Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
    not-my-profile and charliermarsh committed Jan 5, 2023
    Copy the full SHA
    d122492 View commit details
    Browse the repository at this point in the history