8000 pycodestyle config: convert arrays to comma seperated strings (#164) · mirror-dump/python-lsp-server@ca237ce · GitHub
[go: up one dir, main page]

Skip to content

Commit ca237ce

Browse files
lgeigergatesn
authored andcommitted
pycodestyle config: convert arrays to comma seperated strings (python-lsp#164)
1 parent 5f405ee commit ca237ce

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

pyls/_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,7 @@ def debounced(*args, **kwargs):
2323
def camel_to_underscore(string):
2424
s1 = FIRST_CAP_RE.sub(r'\1_\2', string)
2525
return ALL_CAP_RE.sub(r'\1_\2', s1).lower()
26+
27+
28+
def list_to_string(value):
29+
return ",".join(value) if type(value) == list else value

pyls/plugins/pycodestyle_lint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _config_from_files(config_files):
2626

2727
# Then, read the PYLS configuration
2828
ide_conf = config.plugin_settings('pycodestyle')
29-
conf.update({_utils.camel_to_underscore(k): v for k, v in ide_conf.items()})
29+
conf.update({_utils.camel_to_underscore(k): _utils.list_to_string(v) for k, v in ide_conf.items()})
3030

3131
# Finally, read the project configuration
3232
conf.update(_config_from_files(config.find_parents(document.path, CONFIG_FILES)))

test/test_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,13 @@ def call_m():
2424
time.sleep(interval * 2)
2525
call_m()
2626
assert call_m._count == 2
27+
28+
29+
def test_list_to_string():
30+
assert _utils.list_to_string("string") == "string"
31+
assert _utils.list_to_string(["a", "r", "r", "a", "y"]) == "a,r,r,a,y"
32+
33+
34+
def test_camel_to_underscore():
35+
assert _utils.camel_to_underscore("camelCase") == "camel_case"
36+
assert _utils.camel_to_underscore("under_score") == "under_score"

0 commit comments

Comments
 (0)
0