SublimeLinter / SublimeLinter-flake8

SublimeLinter plugin for python, using flake8.
MIT License
184 stars 28 forks source link

Args seem to be getting ignored #118

Closed tomleo closed 3 years ago

tomleo commented 3 years ago

In my project file:

{
    "settings":
    {
        "python_interpreter": "/home/tom/hacking/project/venv/bin/python",
        "linters": {
          "flake8": {
              "env": {"PATH":"/home/tom/hacking/project/venv/"},
              "executable": ["python", "-m", "flake8"],
              "working_dir": "/home/tom/hacking/project/src/backend",
              "args": [
                "--config=/home/tom/hacking/project/src/backend/.flake8",
              ]
          },
        },
    },
}

However all settings from that .flake8 file seem to be getting ignored, mainly line-length options:

# See http://flake8.pycqa.org/en/latest/user/error-codes.html for full list of error codes
[flake8]
max-line-length = 119
exclude = .migrations,local_dev.py
max-complexity = 10
extend-ignore =
    E402, # module level import not at top of file (due to standard_library.install_aliases())
    es/**/urls.py: E501

If I explicitly add the line-length argument, it still get's ignored

    "settings":
    {
        "python_interpreter": "/home/tom/hacking/project/venv/bin/python",
        "linters": {
          "flake8": {
              "env": {"PATH":"/home/tom/hacking/project/venv/"},
              "executable": ["python", "-m", "flake8"],
              "working_dir": "/home/tom/hacking/project/src/backend",
              "args": [
                "--config=/home/tom/hacking/project/src/backend/.flake8",
                "--max-line-length=119",
              ]
          },
        },
    },

It seems as though flake8 is getting called without my wanted arguments. I can confirm that when executing commands from the command-line settings like a longer max-line-length are respected.

FWIW I've also tried the additional "SublimeLinter" line (wasn't sure if that's needed for project settings), anyways it didn't seem to change anything.

    "settings":
    {
        "python_interpreter": "/home/tom/hacking/project/venv/bin/python",
        "SublimeLinter": {
            "linters": {
              "flake8": {
                  "env": {"PATH":"/home/tom/hacking/project/venv/"},
                  "executable": ["python", "-m", "flake8"],
                  "working_dir": "/home/tom/hacking/project/src/backend",
                  "args": [
                    "--config=/home/tom/hacking/project/src/backend/.flake8",
                    "--max-line-length=119",
                  ]
              },
            },
        },
    },

If it's useful I'm using Sublime Text build 4107.

Thanks!

tomleo commented 3 years ago

:facepalm: I asked this same question 2 years ago... https://github.com/SublimeLinter/SublimeLinter-flake8/issues/108

The solution if anyone happens to read this (you might also want to consider using variable expansion, something I didn't do here):

    "settings":
    {
        "SublimeLinter.linters.flake8.env": {"PATH": "/home/tom/hacking/project/venv/"},
        "SublimeLinter.linters.flake8.executable": ["/home/tom/hacking/project/venv/bin/python", "-m", "flake8"],
        "SublimeLinter.linters.flake8.working_dir": "/home/tom/hacking/project/src/backend",
    },