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

Do not enforce line length limit for long URL in docstrings #3051

Closed
jfcherng opened this issue Feb 20, 2023 · 3 comments · Fixed by #3663
Closed

Do not enforce line length limit for long URL in docstrings #3051

jfcherng opened this issue Feb 20, 2023 · 3 comments · Fixed by #3663
Assignees
Labels
question Asking for support or clarification

Comments

@jfcherng
Copy link

Similar to #920 but in docstring

class Foo:
    """
    @see https://looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong.url.com
    """
@charliermarsh
Copy link
Member

For what it's worth, we do allow this:

class Foo:
    """
    See:
        https://looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong.url.com
    """

That is: if the URL is on its own line, we don't flag it. Is that sufficient?

@charliermarsh charliermarsh added the question Asking for support or clarification label Feb 20, 2023
@jfcherng
Copy link
Author

jfcherng commented Feb 21, 2023

For what it's worth, we do allow this:

class Foo:
    """
    See:
        https://looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong.url.com
    """

That is: if the URL is on its own line, we don't flag it. Is that sufficient?

Probably OK for this case but for consistency, it's a little cumbersome for a short URL.

class Foo:
    """
    See:
        https://short.url.com/
    """

v.s.

class Foo:
    """
    @see https://short.url.com/
    """

Okay... so there are various common docstring formats. Not sure how much performance impact it would be for detecting a line is ended with a URL in a multiline string... but it sounds slow.

@jat255
Copy link

jat255 commented Mar 24, 2023

Another issue where I've run into this when I recently started using ruff (wonderful tool, by the way!) is in RST text substitution links, something like the following:

    .. _named link on long line 1: https://qwertyyuiopasdfghjklzxcvbnm.qwertyyuiopasdfghjklzxcvbnm.org/
    .. _named link on long line 2: https://qwertyyuiopasdfghjklzxcvbnm.com/qwertyyuiopasdfghjklzxcvbnm.html#anchor_tag_1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants