Skip to content

Use WPS with PyCharm but without console, rather than built in, LSP like #3586

@Day0Dreamer

Description

@Day0Dreamer

Hey there, I managed to configure WSP using LSP4IJ in PyCharm and good old pipx. I assume you have pipx.

Image

Here's how

1 Install python-lsp-server

# Install pylsp
pipx install "python-lsp-server[flake8]"

# Inject required plugins
pipx inject python-lsp-server wemake-python-styleguide
pipx inject python-lsp-server pyls-flake8

Important: The [flake8] extra does NOT install the flake8 plugin — you must manually inject pyls-flake8.

2 Verify Installation.

pipx runpip python-lsp-server list
# or 
pipx runpip python-lsp-server list | grep -E "(flake8|wemake|pyls-flake8|Flake8-pyproject)"

Expected output:

flake8                    7.x.x
pyls-flake8               0.x.x
wemake-python-styleguide  1.x.x

3 Find pylsp Executable Path

where pylsp

Note the path: C:\Users\Day\.local\bin\pylsp.exe

4 Create LSP server

  1. Settings → Languages & Frameworks → Language Server Protocol → Server Definitions
  2. Click "+" to add a new server
  3. Configure:
Field Value
Name pylsp-flake8
Path C:\Users\Day\.local\bin\pylsp.exe
  1. In the Configuration tab, add this JSON:
{
  "pylsp": {
    "plugins": {
      "flake8": {
        "enabled": true,
        "maxLineLength": 70,
        "select": ["WPS", "E"],
        "ignore": ["WPS111", "WPS602"]
      },
      "pycodestyle": {
        "enabled": false
      },
      "pyflakes": {
        "enabled": false
      }
    }
  }
}

or

{
  "pylsp": {
    "plugins": {
      "flake8": {
        "enabled": true,
        "config": "C:\\...whatever...\\.flake8"
      },
      "pycodestyle": { "enabled": false },
      "pyflakes": { "enabled": false },
      "mccabe": { "enabled": false },
      "pyls_isort": { "enabled": false },
      "pylsp_mypy": { "enabled": false },
      "rope_autoimport": { "enabled": false },
      "rope_completion": { "enabled": false }
    }
  }
}
  1. In Mappings - Language - Languages add the Python language.

  2. Click OK

5 Restart PyCharm

Restart PyCharm completely for the LSP server to initialize.

6 Test Inline Errors

Create a test file with intentional WPS errors:

# test_wps_errors.py
"""Test file with WPS errors."""

# WPS407: Mutable module constant
ITEMS_LIST = []

# WPS110: Wrong variable name
data = {"key": "value"}
obj = object()

def process(x):
    # WPS421: Wrong function call (print)
    print("Processing...")
    # WPS432: Magic number
    return x * 3.14159
  • WPS errors appear as inline squiggles (yellow/orange underlines)
  • Hovering shows the WPS error message

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions