Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ This server can be configured using the `workspace/didChangeConfiguration` metho
| `pylsp.plugins.pycodestyle.indentSize` | `integer` | Set indentation spaces. | `null` |
| `pylsp.plugins.pydocstyle.enabled` | `boolean` | Enable or disable the plugin. | `false` |
| `pylsp.plugins.pydocstyle.convention` | `string` (one of: `'pep257'`, `'numpy'`, `'google'`, `None`) | Choose the basic list of checked errors by specifying an existing convention. | `null` |
| `pylsp.plugins.pydocstyle.addIgnore` | `array` of unique `string` items | Ignore errors and warnings in addition to the specified convention. | `[]` |
| `pylsp.plugins.pydocstyle.addSelect` | `array` of unique `string` items | Select errors and warnings in addition to the specified convention. | `[]` |
| `pylsp.plugins.pydocstyle.addIgnore` | `array` of unique `string` items | Ignore errors and warnings in addition to the basic list of checked errors. | `[]` |
| `pylsp.plugins.pydocstyle.addSelect` | `array` of unique `string` items | Select errors and warnings in addition to the basic list of checked errors. | `[]` |
| `pylsp.plugins.pydocstyle.ignore` | `array` of unique `string` items | Ignore errors and warnings | `[]` |
| `pylsp.plugins.pydocstyle.select` | `array` of unique `string` items | Select errors and warnings | `null` |
| `pylsp.plugins.pydocstyle.match` | `string` | Check only files that exactly match the given regular expression; default is to match files that don't start with 'test_' but end with '.py'. | `"(?!test_).*\\.py"` |
Expand Down
4 changes: 2 additions & 2 deletions pylsp/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@
"type": "string"
},
"uniqueItems": true,
"description": "Ignore errors and warnings in addition to the specified convention."
"description": "Ignore errors and warnings in addition to the basic list of checked errors."
},
"pylsp.plugins.pydocstyle.addSelect": {
"type": "array",
Expand All @@ -405,7 +405,7 @@
"type": "string"
},
"uniqueItems": true,
"description": "Select errors and warnings in addition to the specified convention."
"description": "Select errors and warnings in addition to the basic list of checked errors."
},
"pylsp.plugins.pydocstyle.ignore": {
"type": "array",
Expand Down
11 changes: 5 additions & 6 deletions pylsp/plugins/pydocstyle_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,16 @@ def pylsp_lint(config, workspace, document):

if settings.get("convention"):
args.append("--convention=" + settings["convention"])

if settings.get("addSelect"):
args.append("--add-select=" + ",".join(settings["addSelect"]))
if settings.get("addIgnore"):
args.append("--add-ignore=" + ",".join(settings["addIgnore"]))

elif settings.get("select"):
args.append("--select=" + ",".join(settings["select"]))
elif settings.get("ignore"):
args.append("--ignore=" + ",".join(settings["ignore"]))

if settings.get("addSelect"):
args.append("--add-select=" + ",".join(settings["addSelect"]))
if settings.get("addIgnore"):
args.append("--add-ignore=" + ",".join(settings["addIgnore"]))

log.info("Using pydocstyle args: %s", args)

conf = pydocstyle.config.ConfigurationParser()
Expand Down
22 changes: 22 additions & 0 deletions test/plugins/test_pydocstyle_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ def test_pydocstyle(config, workspace) -> None:
}


def test_pydocstyle_add_ignore_with_select(config, workspace) -> None:
config.update(
{"plugins": {"pydocstyle": {"select": ["D100"], "addIgnore": ["D100"]}}}
)
doc = Document(DOC_URI, workspace, DOC)

diags = pydocstyle_lint.pylsp_lint(config, workspace, doc)

assert not diags


def test_pydocstyle_add_select_with_ignore(config, workspace) -> None:
config.update(
{"plugins": {"pydocstyle": {"ignore": ["D100"], "addSelect": ["D100"]}}}
)
doc = Document(DOC_URI, workspace, DOC)

diags = pydocstyle_lint.pylsp_lint(config, workspace, doc)

assert {diag["code"] for diag in diags} == {"D100", "D103"}


def test_pydocstyle_test_document(config, workspace) -> None:
# The default --match argument excludes test_* documents.
doc = Document(TEST_DOC_URI, workspace, "")
Expand Down