How can I ignore a lint error for a line with Sublime Text 3 Anaconda?
Asked Answered
T

5

38

I'm using Anaconda with Sublime text 3. I have left the lint settings as default with the exception of the following overrides which I've included in a .sublime-project file.

"settings": {
        "anaconda_gutter_marks": true,
        "anaconda_gutter_theme": "alpha",
        "anaconda_linting_behaviour": "always",

    }

I'd like to be able to ignore "line too long" for certain lines, specifically ones with urls in the comments. I like having it for other lines so I would rather not disable it entirely.

I've only found information on doing this for pylint but I'd rather use the default linter if that is possible since that seems to come with its own issues in this plugin.

I've included the sublimelinter tag because anaconda states it's linting is based off of that plugin.

Tranquilize answered 6/5, 2014 at 16:51 Comment(1)
Daniel Rucci, please, accept Nostalg.io answer, if it works for you. At 2018 Anaconda support #noqa. Thanks.Muldrow
U
14

As of today (Oct 15, 2017), it appears to me that you can use the # noqa syntax with Anaconda for Sublime Text 3. For line too long, you would add # noqa E501 to the end of the line.

Example:

shipping_account = models.ForeignKey(Account, related_name='order_shipping_set') # noqa E501
Unclothe answered 15/10, 2017 at 20:41 Comment(1)
I assumed by putting E501 at the end, it would only ignore "line too long" errors. But it seems to ignore all lint errors. (I have a line that's 200 characters, and I added # noqa E231 expecting to see the E501 error show ...it did not though). Is that correct, or am I perhaps doing something wrong?Troytroyer
G
79

To disable lints for specific errors, go to the Anaconda.sublime-settings file (Preferences > Packages Settings > Anaconda > Settings). There you will find several options depending on which linter you are using.

For example, to disable linting for "line too long" for pep8, fill in the following:

"pep8_ignore":
[
    "E501"
],

Also, the easiest way to find out the correct error code is to the view the lint error itself at the bottom of the screen.

Grapery answered 5/3, 2015 at 0:31 Comment(3)
This question asks how to ignore errors on certain lines only, which your answer does not address.Tristram
First time you're changing Anaconda user settings? Go to Preferences > Packages Settings > Anaconda > Settings - User then verbatim use { "pep8_ignore": ["E501"] } in order to get valid JSON.Refinement
@JeffreyBosboom yes but incase anyone else is looking for the ignore all case this is the answer. still useful information and on topicWomera
U
14

As of today (Oct 15, 2017), it appears to me that you can use the # noqa syntax with Anaconda for Sublime Text 3. For line too long, you would add # noqa E501 to the end of the line.

Example:

shipping_account = models.ForeignKey(Account, related_name='order_shipping_set') # noqa E501
Unclothe answered 15/10, 2017 at 20:41 Comment(1)
I assumed by putting E501 at the end, it would only ignore "line too long" errors. But it seems to ignore all lint errors. (I have a line that's 200 characters, and I added # noqa E231 expecting to see the E501 error show ...it did not though). Is that correct, or am I perhaps doing something wrong?Troytroyer
V
11

I am afraid that you can't ignore an error type (like line too long) just for some lines. You can't disable just warnings or violations neither.

It would be possible to implement some custom system like the #noqa comment in flake8 to make the plugin able to just ignore certain lines of code but this has to be implemented as it's not supported by the plugin and there are no plans to use flake8 in replacement of PyFlakes and pep8 that are already being used by separate.

There is a similar (but in a much more abstract way) request already in the issues in the GitHub project, you can find it here https://github.com/DamnWidget/anaconda/issues/142

Viscid answered 6/5, 2014 at 18:0 Comment(5)
Update: @Viscid closed the above-mentioned issue a couple of weeks after posting this. Now using # noqa error_number with certain numbers (E501 included) will work. See the above link (in this answer) for the full list of error numbers that it will work with. Figured an update would save some people some clicks.Winegar
How would I disable all warning and violations? I would like only errors to be displayed.Shingly
Currently is not possible to ignore certain error types, you can always open a new issue in our Github project page and me or any other contributor can study its convenience.Viscid
One way to do achieve this today, is to set {"anaconda_linting": false} and use SublimeLinter-flake8 in combination with # flake8: noqaBeckmann
I think @CraigFischer has the best answer for this issue (out of many similar topics)Wouldst
W
2
  • Go to the Anaconda.sublime-settings file,

    Preferences > Packages Settings > Anaconda > Settings

  • There you will find several options depending on which linter you are using.

    For example, to disable linting for "line too long" for pep8, fill in the following:

    "pep8_ignore":
        [
        "E501"
        ],
    
Woodwork answered 27/9, 2020 at 16:6 Comment(0)
L
1

Preferences > Package Settings > Anaconda > Settings - User

{
    "pep8_max_line_length": 120
}

Lactalbumin answered 27/9, 2020 at 2:3 Comment(1)
a better choice than ignore - set to 100 for pylintTransitive

© 2022 - 2024 — McMap. All rights reserved.