Skip to content

Commit cabac8e

Browse files
agserrano3codegen-bot
and
codegen-bot
authored
Set return type to None for functions without returns (#581)
Co-authored-by: codegen-bot <[email protected]>
1 parent 8a345b9 commit cabac8e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+287
-275
lines changed

pylsp/__main__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
)
2626

2727

28-
def add_arguments(parser):
28+
def add_arguments(parser) -> None:
2929
parser.description = "Python Language Server"
3030

3131
parser.add_argument(
@@ -67,7 +67,7 @@ def add_arguments(parser):
6767
)
6868

6969

70-
def main():
70+
def main() -> None:
7171
parser = argparse.ArgumentParser()
7272
add_arguments(parser)
7373
args = parser.parse_args()
@@ -94,7 +94,7 @@ def _binary_stdio():
9494
return stdin, stdout
9595

9696

97-
def _configure_logger(verbose=0, log_config=None, log_file=None):
97+
def _configure_logger(verbose=0, log_config=None, log_file=None) -> None:
9898
root_logger = logging.root
9999

100100
if log_config:

pylsp/config/config.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _hookexec(
4343

4444

4545
class Config:
46-
def __init__(self, root_uri, init_opts, process_id, capabilities):
46+
def __init__(self, root_uri, init_opts, process_id, capabilities) -> None:
4747
self._root_path = uris.to_fs_path(root_uri)
4848
self._root_uri = root_uri
4949
self._init_opts = init_opts
@@ -185,14 +185,14 @@ def plugin_settings(self, plugin, document_path=None):
185185
.get(plugin, {})
186186
)
187187

188-
def update(self, settings):
188+
def update(self, settings) -> None:
189189
"""Recursively merge the given settings into the current settings."""
190190
self.settings.cache_clear()
191191
self._settings = settings
192192
log.info("Updated settings to %s", self._settings)
193193
self._update_disabled_plugins()
194194

195-
def _update_disabled_plugins(self):
195+
def _update_disabled_plugins(self) -> None:
196196
# All plugins default to enabled
197197
self._disabled_plugins = [
198198
plugin

pylsp/config/source.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
class ConfigSource:
1313
"""Base class for implementing a config source."""
1414

15-
def __init__(self, root_path):
15+
def __init__(self, root_path) -> None:
1616
self.root_path = root_path
1717
self.is_windows = sys.platform == "win32"
1818
self.xdg_home = os.environ.get(
1919
"XDG_CONFIG_HOME", os.path.expanduser("~/.config")
2020
)
2121

22-
def user_config(self):
22+
def user_config(self) -> None:
2323
"""Return user-level (i.e. home directory) configuration."""
2424
raise NotImplementedError()
2525

26-
def project_config(self, document_path):
26+
def project_config(self, document_path) -> None:
2727
"""Return project-level (i.e. workspace directory) configuration."""
2828
raise NotImplementedError()
2929

pylsp/hookspecs.py

+26-24
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ def pylsp_code_actions(config, workspace, document, range, context):
1010

1111

1212
@hookspec
13-
def pylsp_code_lens(config, workspace, document):
13+
def pylsp_code_lens(config, workspace, document) -> None:
1414
pass
1515

1616

1717
@hookspec
18-
def pylsp_commands(config, workspace):
18+
def pylsp_commands(config, workspace) -> None:
1919
"""The list of command strings supported by the server.
2020
2121
Returns:
@@ -24,110 +24,112 @@ def pylsp_commands(config, workspace):
2424

2525

2626
@hookspec
27-
def pylsp_completions(config, workspace, document, position, ignored_names):
27+
def pylsp_completions(config, workspace, document, position, ignored_names) -> None:
2828
pass
2929

3030

3131
@hookspec(firstresult=True)
32-
def pylsp_completion_item_resolve(config, workspace, document, completion_item):
32+
def pylsp_completion_item_resolve(config, workspace, document, completion_item) -> None:
3333
pass
3434

3535

3636
@hookspec
37-
def pylsp_definitions(config, workspace, document, position):
37+
def pylsp_definitions(config, workspace, document, position) -> None:
3838
pass
3939

4040

4141
@hookspec
42-
def pylsp_dispatchers(config, workspace):
42+
def pylsp_dispatchers(config, workspace) -> None:
4343
pass
4444

4545

4646
@hookspec
47-
def pylsp_document_did_open(config, workspace, document):
47+
def pylsp_document_did_open(config, workspace, document) -> None:
4848
pass
4949

5050

5151
@hookspec
52-
def pylsp_document_did_save(config, workspace, document):
52+
def pylsp_document_did_save(config, workspace, document) -> None:
5353
pass
5454

5555

5656
@hookspec
57-
def pylsp_document_highlight(config, workspace, document, position):
57+
def pylsp_document_highlight(config, workspace, document, position) -> None:
5858
pass
5959

6060

6161
@hookspec
62-
def pylsp_document_symbols(config, workspace, document):
62+
def pylsp_document_symbols(config, workspace, document) -> None:
6363
pass
6464

6565

6666
@hookspec(firstresult=True)
67-
def pylsp_execute_command(config, workspace, command, arguments):
67+
def pylsp_execute_command(config, workspace, command, arguments) -> None:
6868
pass
6969

7070

7171
@hookspec
72-
def pylsp_experimental_capabilities(config, workspace):
72+
def pylsp_experimental_capabilities(config, workspace) -> None:
7373
pass
7474

7575

7676
@hookspec
77-
def pylsp_folding_range(config, workspace, document):
77+
def pylsp_folding_range(config, workspace, document) -> None:
7878
pass
7979

8080

8181
@hookspec(firstresult=True)
82-
def pylsp_format_document(config, workspace, document, options):
82+
def pylsp_format_document(config, workspace, document, options) -> None:
8383
pass
8484

8585

8686
@hookspec(firstresult=True)
87-
def pylsp_format_range(config, workspace, document, range, options):
87+
def pylsp_format_range(config, workspace, document, range, options) -> None:
8888
pass
8989

9090

9191
@hookspec(firstresult=True)
92-
def pylsp_hover(config, workspace, document, position):
92+
def pylsp_hover(config, workspace, document, position) -> None:
9393
pass
9494

9595

9696
@hookspec
97-
def pylsp_initialize(config, workspace):
97+
def pylsp_initialize(config, workspace) -> None:
9898
pass
9999

100100

101101
@hookspec
102-
def pylsp_initialized():
102+
def pylsp_initialized() -> None:
103103
pass
104104

105105

106106
@hookspec
107-
def pylsp_lint(config, workspace, document, is_saved):
107+
def pylsp_lint(config, workspace, document, is_saved) -> None:
108108
pass
109109

110110

111111
@hookspec
112-
def pylsp_references(config, workspace, document, position, exclude_declaration):
112+
def pylsp_references(
113+
config, workspace, document, position, exclude_declaration
114+
) -> None:
113115
pass
114116

115117

116118
@hookspec(firstresult=True)
117-
def pylsp_rename(config, workspace, document, position, new_name):
119+
def pylsp_rename(config, workspace, document, position, new_name) -> None:
118120
pass
119121

120122

121123
@hookspec
122-
def pylsp_settings(config):
124+
def pylsp_settings(config) -> None:
123125
pass
124126

125127

126128
@hookspec(firstresult=True)
127-
def pylsp_signature_help(config, workspace, document, position):
129+
def pylsp_signature_help(config, workspace, document, position) -> None:
128130
pass
129131

130132

131133
@hookspec
132-
def pylsp_workspace_configuration_changed(config, workspace):
134+
def pylsp_workspace_configuration_changed(config, workspace) -> None:
133135
pass

pylsp/plugins/_resolvers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# ---- Base class
1616
# -----------------------------------------------------------------------------
1717
class Resolver:
18-
def __init__(self, callback, resolve_on_error, time_to_live=60 * 30):
18+
def __init__(self, callback, resolve_on_error, time_to_live=60 * 30) -> None:
1919
self.callback = callback
2020
self.resolve_on_error = resolve_on_error
2121
self._cache = {}
@@ -33,7 +33,7 @@ def cached_modules(self):
3333
def cached_modules(self, new_value):
3434
self._cached_modules = set(new_value)
3535

36-
def clear_outdated(self):
36+
def clear_outdated(self) -> None:
3737
now = self.time_key()
3838
to_clear = [timestamp for timestamp in self._cache_ttl if timestamp < now]
3939
for time_key in to_clear:

pylsp/plugins/_rope_task_handle.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PylspJobSet(BaseJobSet):
1919
_report_iter: ContextManager
2020
job_name: str = ""
2121

22-
def __init__(self, count: Optional[int], report_iter: ContextManager):
22+
def __init__(self, count: Optional[int], report_iter: ContextManager) -> None:
2323
if count is not None:
2424
self.count = count
2525
self._reporter = report_iter.__enter__()
@@ -57,7 +57,7 @@ def increment(self) -> None:
5757
self._report()
5858

5959
@throttle(0.5)
60-
def _report(self):
60+
def _report(self) -> None:
6161
percent = int(self.get_percent_done())
6262
message = f"{self.job_name} {self.done}/{self.count}"
6363
log.debug(f"Reporting {message} {percent}%")
@@ -72,7 +72,7 @@ class PylspTaskHandle(BaseTaskHandle):
7272
workspace: Workspace
7373
_report: Callable[[str, str], None]
7474

75-
def __init__(self, workspace: Workspace):
75+
def __init__(self, workspace: Workspace) -> None:
7676
self.workspace = workspace
7777
self.job_sets = []
7878
self.observers = []

pylsp/plugins/preload_imports.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def pylsp_settings():
6767

6868

6969
@hookimpl
70-
def pylsp_initialize(config):
70+
def pylsp_initialize(config) -> None:
7171
for mod_name in config.plugin_settings("preload").get("modules", []):
7272
try:
7373
__import__(mod_name)

pylsp/plugins/pycodestyle_lint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def pylsp_lint(workspace, document):
6565

6666

6767
class PyCodeStyleDiagnosticReport(pycodestyle.BaseReport):
68-
def __init__(self, options):
68+
def __init__(self, options) -> None:
6969
self.diagnostics = []
7070
super().__init__(options=options)
7171

pylsp/plugins/pydocstyle_lint.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def _parse_diagnostic(document, error):
115115

116116

117117
@contextlib.contextmanager
118-
def _patch_sys_argv(arguments):
118+
def _patch_sys_argv(arguments) -> None:
119119
old_args = sys.argv
120120

121121
# Preserve argv[0] since it's the executable

pylsp/plugins/pyflakes_lint.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ def pylsp_lint(workspace, document):
3232

3333

3434
class PyflakesDiagnosticReport:
35-
def __init__(self, lines):
35+
def __init__(self, lines) -> None:
3636
self.lines = lines
3737
self.diagnostics = []
3838

39-
def unexpectedError(self, _filename, msg): # pragma: no cover
39+
def unexpectedError(self, _filename, msg) -> None: # pragma: no cover
4040
err_range = {
4141
"start": {"line": 0, "character": 0},
4242
"end": {"line": 0, "character": 0},
@@ -50,7 +50,7 @@ def unexpectedError(self, _filename, msg): # pragma: no cover
5050
}
5151
)
5252

53-
def syntaxError(self, _filename, msg, lineno, offset, text):
53+
def syntaxError(self, _filename, msg, lineno, offset, text) -> None:
5454
# We've seen that lineno and offset can sometimes be None
5555
lineno = lineno or 1
5656
offset = offset or 0
@@ -71,7 +71,7 @@ def syntaxError(self, _filename, msg, lineno, offset, text):
7171
}
7272
)
7373

74-
def flake(self, message):
74+
def flake(self, message) -> None:
7575
"""Get message like <filename>:<lineno>: <msg>"""
7676
err_range = {
7777
"start": {"line": message.lineno - 1, "character": message.col},

pylsp/plugins/rope_autoimport.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
class AutoimportCache:
3030
"""Handles the cache creation."""
3131

32-
def __init__(self):
32+
def __init__(self) -> None:
3333
self.thread = None
3434

3535
def reload_cache(
@@ -66,7 +66,7 @@ def _reload_cache(
6666
workspace: Workspace,
6767
autoimport: AutoImport,
6868
resources: Optional[List[Resource]] = None,
69-
):
69+
) -> None:
7070
task_handle = PylspTaskHandle(workspace)
7171
autoimport.generate_cache(task_handle=task_handle, resources=resources)
7272
autoimport.generate_modules_cache(task_handle=task_handle)
@@ -365,7 +365,7 @@ def pylsp_code_actions(
365365

366366

367367
@hookimpl
368-
def pylsp_initialize(config: Config, workspace: Workspace):
368+
def pylsp_initialize(config: Config, workspace: Workspace) -> None:
369369
"""Initialize AutoImport.
370370
371371
Generates the cache for local and global items.
@@ -374,7 +374,7 @@ def pylsp_initialize(config: Config, workspace: Workspace):
374374

375375

376376
@hookimpl
377-
def pylsp_document_did_open(config: Config, workspace: Workspace):
377+
def pylsp_document_did_open(config: Config, workspace: Workspace) -> None:
378378
"""Initialize AutoImport.
379379
380380
Generates the cache for local and global items.
@@ -383,13 +383,15 @@ def pylsp_document_did_open(config: Config, workspace: Workspace):
383383

384384

385385
@hookimpl
386-
def pylsp_document_did_save(config: Config, workspace: Workspace, document: Document):
386+
def pylsp_document_did_save(
387+
config: Config, workspace: Workspace, document: Document
388+
) -> None:
387389
"""Update the names associated with this document."""
388390
cache.reload_cache(config, workspace, [document])
389391

390392

391393
@hookimpl
392-
def pylsp_workspace_configuration_changed(config: Config, workspace: Workspace):
394+
def pylsp_workspace_configuration_changed(config: Config, workspace: Workspace) -> None:
393395
"""
394396
Initialize autoimport if it has been enabled through a
395397
workspace/didChangeConfiguration message from the frontend.

0 commit comments

Comments
 (0)