Skip to content

Commit 7f89601

Browse files
committed
Fix pydocstyle add-select and add-ignore settings
1 parent a362006 commit 7f89601

4 files changed

Lines changed: 31 additions & 10 deletions

File tree

CONFIGURATION.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ This server can be configured using the `workspace/didChangeConfiguration` metho
5757
| `pylsp.plugins.pycodestyle.indentSize` | `integer` | Set indentation spaces. | `null` |
5858
| `pylsp.plugins.pydocstyle.enabled` | `boolean` | Enable or disable the plugin. | `false` |
5959
| `pylsp.plugins.pydocstyle.convention` | `string` (one of: `'pep257'`, `'numpy'`, `'google'`, `None`) | Choose the basic list of checked errors by specifying an existing convention. | `null` |
60-
| `pylsp.plugins.pydocstyle.addIgnore` | `array` of unique `string` items | Ignore errors and warnings in addition to the specified convention. | `[]` |
61-
| `pylsp.plugins.pydocstyle.addSelect` | `array` of unique `string` items | Select errors and warnings in addition to the specified convention. | `[]` |
60+
| `pylsp.plugins.pydocstyle.addIgnore` | `array` of unique `string` items | Ignore errors and warnings in addition to the basic list of checked errors. | `[]` |
61+
| `pylsp.plugins.pydocstyle.addSelect` | `array` of unique `string` items | Select errors and warnings in addition to the basic list of checked errors. | `[]` |
6262
| `pylsp.plugins.pydocstyle.ignore` | `array` of unique `string` items | Ignore errors and warnings | `[]` |
6363
| `pylsp.plugins.pydocstyle.select` | `array` of unique `string` items | Select errors and warnings | `null` |
6464
| `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"` |

pylsp/config/schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
"type": "string"
397397
},
398398
"uniqueItems": true,
399-
"description": "Ignore errors and warnings in addition to the specified convention."
399+
"description": "Ignore errors and warnings in addition to the basic list of checked errors."
400400
},
401401
"pylsp.plugins.pydocstyle.addSelect": {
402402
"type": "array",
@@ -405,7 +405,7 @@
405405
"type": "string"
406406
},
407407
"uniqueItems": true,
408-
"description": "Select errors and warnings in addition to the specified convention."
408+
"description": "Select errors and warnings in addition to the basic list of checked errors."
409409
},
410410
"pylsp.plugins.pydocstyle.ignore": {
411411
"type": "array",

pylsp/plugins/pydocstyle_lint.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,16 @@ def pylsp_lint(config, workspace, document):
4747

4848
if settings.get("convention"):
4949
args.append("--convention=" + settings["convention"])
50-
51-
if settings.get("addSelect"):
52-
args.append("--add-select=" + ",".join(settings["addSelect"]))
53-
if settings.get("addIgnore"):
54-
args.append("--add-ignore=" + ",".join(settings["addIgnore"]))
55-
5650
elif settings.get("select"):
5751
args.append("--select=" + ",".join(settings["select"]))
5852
elif settings.get("ignore"):
5953
args.append("--ignore=" + ",".join(settings["ignore"]))
6054

55+
if settings.get("addSelect"):
56+
args.append("--add-select=" + ",".join(settings["addSelect"]))
57+
if settings.get("addIgnore"):
58+
args.append("--add-ignore=" + ",".join(settings["addIgnore"]))
59+
6160
log.info("Using pydocstyle args: %s", args)
6261

6362
conf = pydocstyle.config.ConfigurationParser()

test/plugins/test_pydocstyle_lint.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ def test_pydocstyle(config, workspace) -> None:
3838
}
3939

4040

41+
def test_pydocstyle_add_ignore_with_select(config, workspace) -> None:
42+
config.update(
43+
{"plugins": {"pydocstyle": {"select": ["D100"], "addIgnore": ["D100"]}}}
44+
)
45+
doc = Document(DOC_URI, workspace, DOC)
46+
47+
diags = pydocstyle_lint.pylsp_lint(config, workspace, doc)
48+
49+
assert not diags
50+
51+
52+
def test_pydocstyle_add_select_with_ignore(config, workspace) -> None:
53+
config.update(
54+
{"plugins": {"pydocstyle": {"ignore": ["D100"], "addSelect": ["D100"]}}}
55+
)
56+
doc = Document(DOC_URI, workspace, DOC)
57+
58+
diags = pydocstyle_lint.pylsp_lint(config, workspace, doc)
59+
60+
assert {diag["code"] for diag in diags} == {"D100", "D103"}
61+
62+
4163
def test_pydocstyle_test_document(config, workspace) -> None:
4264
# The default --match argument excludes test_* documents.
4365
doc = Document(TEST_DOC_URI, workspace, "")

0 commit comments

Comments
 (0)