GeezerVison is showing github.com — Set return type to `None` for functions without returns (#581) · deepnote/python-lsp-server@cabac8e
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: pylsp/__main__.py +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 25 | 25 | ) | 26 | 26 |
| 27 | 27 |
| 28 | | -def add_arguments(parser): | | 28 | +def add_arguments(parser) -> None: | 29 | 29 | parser.description = "Python Language Server" | 30 | 30 |
| 31 | 31 | parser.add_argument( | @@ -67,7 +67,7 @@ def add_arguments(parser): | 67 | 67 | ) | 68 | 68 |
| 69 | 69 |
| 70 | | -def main(): | | 70 | +def main() -> None: | 71 | 71 | parser = argparse.ArgumentParser() | 72 | 72 | add_arguments(parser) | 73 | 73 | args = parser.parse_args() | @@ -94,7 +94,7 @@ def _binary_stdio(): | 94 | 94 | return stdin, stdout | 95 | 95 |
| 96 | 96 |
| 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: | 98 | 98 | root_logger = logging.root | 99 | 99 |
| 100 | 100 | if log_config: | |
Collapse file Copy file name to clipboardExpand all lines: pylsp/config/config.py +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -43,7 +43,7 @@ def _hookexec( | 43 | 43 |
| 44 | 44 |
| 45 | 45 | 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: | 47 | 47 | self._root_path = uris.to_fs_path(root_uri) | 48 | 48 | self._root_uri = root_uri | 49 | 49 | self._init_opts = init_opts | @@ -185,14 +185,14 @@ def plugin_settings(self, plugin, document_path=None): | 185 | 185 | .get(plugin, {}) | 186 | 186 | ) | 187 | 187 |
| 188 | | - def update(self, settings): | | 188 | + def update(self, settings) -> None: | 189 | 189 | """Recursively merge the given settings into the current settings.""" | 190 | 190 | self.settings.cache_clear() | 191 | 191 | self._settings = settings | 192 | 192 | log.info("Updated settings to %s", self._settings) | 193 | 193 | self._update_disabled_plugins() | 194 | 194 |
| 195 | | - def _update_disabled_plugins(self): | | 195 | + def _update_disabled_plugins(self) -> None: | 196 | 196 | # All plugins default to enabled | 197 | 197 | self._disabled_plugins = [ | 198 | 198 | plugin | |
Collapse file Copy file name to clipboardExpand all lines: pylsp/config/source.py +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 | class ConfigSource: | 13 | 13 | """Base class for implementing a config source.""" | 14 | 14 |
| 15 | | - def __init__(self, root_path): | | 15 | + def __init__(self, root_path) -> None: | 16 | 16 | self.root_path = root_path | 17 | 17 | self.is_windows = sys.platform == "win32" | 18 | 18 | self.xdg_home = os.environ.get( | 19 | 19 | "XDG_CONFIG_HOME", os.path.expanduser("~/.config") | 20 | 20 | ) | 21 | 21 |
| 22 | | - def user_config(self): | | 22 | + def user_config(self) -> None: | 23 | 23 | """Return user-level (i.e. home directory) configuration.""" | 24 | 24 | raise NotImplementedError() | 25 | 25 |
| 26 | | - def project_config(self, document_path): | | 26 | + def project_config(self, document_path) -> None: | 27 | 27 | """Return project-level (i.e. workspace directory) configuration.""" | 28 | 28 | raise NotImplementedError() | 29 | 29 |
| |
Collapse file Copy file name to clipboardExpand all lines: pylsp/hookspecs.py +26-24Lines changed: 26 additions & 24 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,12 +10,12 @@ def pylsp_code_actions(config, workspace, document, range, context): | 10 | 10 |
| 11 | 11 |
| 12 | 12 | @hookspec | 13 | | -def pylsp_code_lens(config, workspace, document): | | 13 | +def pylsp_code_lens(config, workspace, document) -> None: | 14 | 14 | pass | 15 | 15 |
| 16 | 16 |
| 17 | 17 | @hookspec | 18 | | -def pylsp_commands(config, workspace): | | 18 | +def pylsp_commands(config, workspace) -> None: | 19 | 19 | """The list of command strings supported by the server. | 20 | 20 |
| 21 | 21 | Returns: | @@ -24,110 +24,112 @@ def pylsp_commands(config, workspace): | 24 | 24 |
| 25 | 25 |
| 26 | 26 | @hookspec | 27 | | -def pylsp_completions(config, workspace, document, position, ignored_names): | | 27 | +def pylsp_completions(config, workspace, document, position, ignored_names) -> None: | 28 | 28 | pass | 29 | 29 |
| 30 | 30 |
| 31 | 31 | @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: | 33 | 33 | pass | 34 | 34 |
| 35 | 35 |
| 36 | 36 | @hookspec | 37 | | -def pylsp_definitions(config, workspace, document, position): | | 37 | +def pylsp_definitions(config, workspace, document, position) -> None: | 38 | 38 | pass | 39 | 39 |
| 40 | 40 |
| 41 | 41 | @hookspec | 42 | | -def pylsp_dispatchers(config, workspace): | | 42 | +def pylsp_dispatchers(config, workspace) -> None: | 43 | 43 | pass | 44 | 44 |
| 45 | 45 |
| 46 | 46 | @hookspec | 47 | | -def pylsp_document_did_open(config, workspace, document): | | 47 | +def pylsp_document_did_open(config, workspace, document) -> None: | 48 | 48 | pass | 49 | 49 |
| 50 | 50 |
| 51 | 51 | @hookspec | 52 | | -def pylsp_document_did_save(config, workspace, document): | | 52 | +def pylsp_document_did_save(config, workspace, document) -> None: | 53 | 53 | pass | 54 | 54 |
| 55 | 55 |
| 56 | 56 | @hookspec | 57 | | -def pylsp_document_highlight(config, workspace, document, position): | | 57 | +def pylsp_document_highlight(config, workspace, document, position) -> None: | 58 | 58 | pass | 59 | 59 |
| 60 | 60 |
| 61 | 61 | @hookspec | 62 | | -def pylsp_document_symbols(config, workspace, document): | | 62 | +def pylsp_document_symbols(config, workspace, document) -> None: | 63 | 63 | pass | 64 | 64 |
| 65 | 65 |
| 66 | 66 | @hookspec(firstresult=True) | 67 | | -def pylsp_execute_command(config, workspace, command, arguments): | | 67 | +def pylsp_execute_command(config, workspace, command, arguments) -> None: | 68 | 68 | pass | 69 | 69 |
| 70 | 70 |
| 71 | 71 | @hookspec | 72 | | -def pylsp_experimental_capabilities(config, workspace): | | 72 | +def pylsp_experimental_capabilities(config, workspace) -> None: | 73 | 73 | pass | 74 | 74 |
| 75 | 75 |
| 76 | 76 | @hookspec | 77 | | -def pylsp_folding_range(config, workspace, document): | | 77 | +def pylsp_folding_range(config, workspace, document) -> None: | 78 | 78 | pass | 79 | 79 |
| 80 | 80 |
| 81 | 81 | @hookspec(firstresult=True) | 82 | | -def pylsp_format_document(config, workspace, document, options): | | 82 | +def pylsp_format_document(config, workspace, document, options) -> None: | 83 | 83 | pass | 84 | 84 |
| 85 | 85 |
| 86 | 86 | @hookspec(firstresult=True) | 87 | | -def pylsp_format_range(config, workspace, document, range, options): | | 87 | +def pylsp_format_range(config, workspace, document, range, options) -> None: | 88 | 88 | pass | 89 | 89 |
| 90 | 90 |
| 91 | 91 | @hookspec(firstresult=True) | 92 | | -def pylsp_hover(config, workspace, document, position): | | 92 | +def pylsp_hover(config, workspace, document, position) -> None: | 93 | 93 | pass | 94 | 94 |
| 95 | 95 |
| 96 | 96 | @hookspec | 97 | | -def pylsp_initialize(config, workspace): | | 97 | +def pylsp_initialize(config, workspace) -> None: | 98 | 98 | pass | 99 | 99 |
| 100 | 100 |
| 101 | 101 | @hookspec | 102 | | -def pylsp_initialized(): | | 102 | +def pylsp_initialized() -> None: | 103 | 103 | pass | 104 | 104 |
| 105 | 105 |
| 106 | 106 | @hookspec | 107 | | -def pylsp_lint(config, workspace, document, is_saved): | | 107 | +def pylsp_lint(config, workspace, document, is_saved) -> None: | 108 | 108 | pass | 109 | 109 |
| 110 | 110 |
| 111 | 111 | @hookspec | 112 | | -def pylsp_references(config, workspace, document, position, exclude_declaration): | | 112 | +def pylsp_references( | | 113 | + config, workspace, document, position, exclude_declaration | | 114 | +) -> None: | 113 | 115 | pass | 114 | 116 |
| 115 | 117 |
| 116 | 118 | @hookspec(firstresult=True) | 117 | | -def pylsp_rename(config, workspace, document, position, new_name): | | 119 | +def pylsp_rename(config, workspace, document, position, new_name) -> None: | 118 | 120 | pass | 119 | 121 |
| 120 | 122 |
| 121 | 123 | @hookspec | 122 | | -def pylsp_settings(config): | | 124 | +def pylsp_settings(config) -> None: | 123 | 125 | pass | 124 | 126 |
| 125 | 127 |
| 126 | 128 | @hookspec(firstresult=True) | 127 | | -def pylsp_signature_help(config, workspace, document, position): | | 129 | +def pylsp_signature_help(config, workspace, document, position) -> None: | 128 | 130 | pass | 129 | 131 |
| 130 | 132 |
| 131 | 133 | @hookspec | 132 | | -def pylsp_workspace_configuration_changed(config, workspace): | | 134 | +def pylsp_workspace_configuration_changed(config, workspace) -> None: | 133 | 135 | pass |
Collapse file Copy file name to clipboardExpand all lines: pylsp/plugins/_resolvers.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 15 | 15 | # ---- Base class | 16 | 16 | # ----------------------------------------------------------------------------- | 17 | 17 | 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: | 19 | 19 | self.callback = callback | 20 | 20 | self.resolve_on_error = resolve_on_error | 21 | 21 | self._cache = {} | @@ -33,7 +33,7 @@ def cached_modules(self): | 33 | 33 | def cached_modules(self, new_value): | 34 | 34 | self._cached_modules = set(new_value) | 35 | 35 |
| 36 | | - def clear_outdated(self): | | 36 | + def clear_outdated(self) -> None: | 37 | 37 | now = self.time_key() | 38 | 38 | to_clear = [timestamp for timestamp in self._cache_ttl if timestamp < now] | 39 | 39 | for time_key in to_clear: | |
Collapse file Copy file name to clipboardExpand all lines: pylsp/plugins/_rope_task_handle.py +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -19,7 +19,7 @@ class PylspJobSet(BaseJobSet): | 19 | 19 | _report_iter: ContextManager | 20 | 20 | job_name: str = "" | 21 | 21 |
| 22 | | - def __init__(self, count: Optional[int], report_iter: ContextManager): | | 22 | + def __init__(self, count: Optional[int], report_iter: ContextManager) -> None: | 23 | 23 | if count is not None: | 24 | 24 | self.count = count | 25 | 25 | self._reporter = report_iter.__enter__() | @@ -57,7 +57,7 @@ def increment(self) -> None: | 57 | 57 | self._report() | 58 | 58 |
| 59 | 59 | @throttle(0.5) | 60 | | - def _report(self): | | 60 | + def _report(self) -> None: | 61 | 61 | percent = int(self.get_percent_done()) | 62 | 62 | message = f"{self.job_name} {self.done}/{self.count}" | 63 | 63 | log.debug(f"Reporting {message} {percent}%") | @@ -72,7 +72,7 @@ class PylspTaskHandle(BaseTaskHandle): | 72 | 72 | workspace: Workspace | 73 | 73 | _report: Callable[[str, str], None] | 74 | 74 |
| 75 | | - def __init__(self, workspace: Workspace): | | 75 | + def __init__(self, workspace: Workspace) -> None: | 76 | 76 | self.workspace = workspace | 77 | 77 | self.job_sets = [] | 78 | 78 | self.observers = [] | |
Collapse file Copy file name to clipboardExpand all lines: pylsp/plugins/preload_imports.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -67,7 +67,7 @@ def pylsp_settings(): | 67 | 67 |
| 68 | 68 |
| 69 | 69 | @hookimpl | 70 | | -def pylsp_initialize(config): | | 70 | +def pylsp_initialize(config) -> None: | 71 | 71 | for mod_name in config.plugin_settings("preload").get("modules", []): | 72 | 72 | try: | 73 | 73 | __import__(mod_name) | |
Collapse file Copy file name to clipboardExpand all lines: pylsp/plugins/pycodestyle_lint.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -65,7 +65,7 @@ def pylsp_lint(workspace, document): | 65 | 65 |
| 66 | 66 |
| 67 | 67 | class PyCodeStyleDiagnosticReport(pycodestyle.BaseReport): | 68 | | - def __init__(self, options): | | 68 | + def __init__(self, options) -> None: | 69 | 69 | self.diagnostics = [] | 70 | 70 | super().__init__(options=options) | 71 | 71 |
| |
Collapse file Copy file name to clipboardExpand all lines: pylsp/plugins/pydocstyle_lint.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -115,7 +115,7 @@ def _parse_diagnostic(document, error): | 115 | 115 |
| 116 | 116 |
| 117 | 117 | @contextlib.contextmanager | 118 | | -def _patch_sys_argv(arguments): | | 118 | +def _patch_sys_argv(arguments) -> None: | 119 | 119 | old_args = sys.argv | 120 | 120 |
| 121 | 121 | # Preserve argv[0] since it's the executable | |
Collapse file Copy file name to clipboardExpand all lines: pylsp/plugins/pyflakes_lint.py +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -32,11 +32,11 @@ def pylsp_lint(workspace, document): | 32 | 32 |
| 33 | 33 |
| 34 | 34 | class PyflakesDiagnosticReport: | 35 | | - def __init__(self, lines): | | 35 | + def __init__(self, lines) -> None: | 36 | 36 | self.lines = lines | 37 | 37 | self.diagnostics = [] | 38 | 38 |
| 39 | | - def unexpectedError(self, _filename, msg): # pragma: no cover | | 39 | + def unexpectedError(self, _filename, msg) -> None: # pragma: no cover | 40 | 40 | err_range = { | 41 | 41 | "start": {"line": 0, "character": 0}, | 42 | 42 | "end": {"line": 0, "character": 0}, | @@ -50,7 +50,7 @@ def unexpectedError(self, _filename, msg): # pragma: no cover | 50 | 50 | } | 51 | 51 | ) | 52 | 52 |
| 53 | | - def syntaxError(self, _filename, msg, lineno, offset, text): | | 53 | + def syntaxError(self, _filename, msg, lineno, offset, text) -> None: | 54 | 54 | # We've seen that lineno and offset can sometimes be None | 55 | 55 | lineno = lineno or 1 | 56 | 56 | offset = offset or 0 | @@ -71,7 +71,7 @@ def syntaxError(self, _filename, msg, lineno, offset, text): | 71 | 71 | } | 72 | 72 | ) | 73 | 73 |
| 74 | | - def flake(self, message): | | 74 | + def flake(self, message) -> None: | 75 | 75 | """Get message like <filename>:<lineno>: <msg>""" | 76 | 76 | err_range = { | 77 | 77 | "start": {"line": message.lineno - 1, "character": message.col}, | |
|