Skip to content

Commit 2a70d8a

Browse files
committed
make sure all config options are used
1 parent 98307ce commit 2a70d8a

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

pylanguagetool/api.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ def check(input_text, api_url, lang, mother_tongue=None, preferred_variants=None
5151
enabled_rules=None, disabled_rules=None,
5252
enabled_categories=None, disabled_categories=None,
5353
enabled_only=False, picky=False, verbose=False,
54-
pwl=None, username=None, api_key=None,
55-
**kwargs):
54+
pwl=None, username=None, api_key=None):
5655
"""
5756
Check given text and return API response as a dictionary.
5857
@@ -110,6 +109,12 @@ def check(input_text, api_url, lang, mother_tongue=None, preferred_variants=None
110109
Personal world list. A custom dictionary of words that should be
111110
excluded from spell checking errors.
112111
112+
username (str):
113+
For Premium API
114+
115+
api_key (str):
116+
For Premium API
117+
113118
Returns:
114119
dict:
115120
A dictionary representation of the JSON API response.

pylanguagetool/cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,16 @@ def main():
238238
print("or use the languagetool integration in TeXstudio.")
239239
sys.exit(3)
240240
check_text = converters.convert(input_text, inputtype)
241+
config_not_needed_in_api = [
242+
"version", "no_color", "clipboard", "single_line",
243+
"input_type", "input file", "explain_rule", "rules",
244+
"rule_categories"
245+
]
246+
config_for_api = {k: v for k, v in config.items() if k not in config_not_needed_in_api}
241247
if config["single_line"]:
242248
found = False
243249
for line in check_text.splitlines():
244-
response = api.check(line, **config)
250+
response = api.check(line, **config_for_api)
245251
print_errors(response,
246252
config["api_url"],
247253
not config["no_color"],
@@ -254,7 +260,7 @@ def main():
254260
sys.exit(1)
255261

256262
else:
257-
response = api.check(check_text, **config)
263+
response = api.check(check_text, **config_for_api)
258264
print_errors(response,
259265
config["api_url"],
260266
not config["no_color"],

0 commit comments

Comments
 (0)