diff options
author | Adrian Herrmann <adrian.herrmann@qt.io> | 2024-06-06 12:44:22 +0200 |
---|---|---|
committer | Adrian Herrmann <adrian.herrmann@qt.io> | 2024-06-21 12:43:56 +0200 |
commit | 12e370d38ab0f88c6ae555793ed5ac6a18343255 (patch) | |
tree | 28b5a25972f7ceec46eb69e73dcd930580ea3c94 /tools/snippets_translate | |
parent | a5308626119ed39a9a367117aa4a16c1a3970185 (diff) |
Fix flake8 and typing issues
Fix a number of miscellaneous flake8 and typing issues exposed after
updating to the modern typing syntax from 3.10 onwards.
Task-number: PYSIDE-2786
Change-Id: I5476d1208dd1da3fa93bdec02bc6124a80b247fc
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'tools/snippets_translate')
-rw-r--r-- | tools/snippets_translate/main.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/snippets_translate/main.py b/tools/snippets_translate/main.py index faa07a0b0..9e63dd8d0 100644 --- a/tools/snippets_translate/main.py +++ b/tools/snippets_translate/main.py @@ -201,7 +201,7 @@ def overriden_snippet_lines(lines: list[str], start_id: str) -> list[str]: return result -def get_snippet_override(start_id: str, rel_path: str) -> list[str]: +def get_snippet_override(start_id: str, rel_path: Path) -> list[str]: """Check if the snippet is overridden by a local file under sources/pyside6/doc/snippets.""" file_start_id = start_id.replace(' ', '_') @@ -243,14 +243,14 @@ def _get_snippets(lines: list[str], # Find the end of the snippet j = i while j < len(lines): - l = lines[j] + line = lines[j] j += 1 # Add the line to the snippet - snippet.append(l) + snippet.append(line) # Check if the snippet is complete - if start_id in get_snippet_ids(l, pattern): + if start_id in get_snippet_ids(line, pattern): # End of snippet snippet[len(snippet) - 1] = id_line snippets[start_id] = snippet @@ -259,7 +259,7 @@ def _get_snippets(lines: list[str], return snippets -def get_python_example_snippet_override(start_id: str, rel_path: str) -> list[str]: +def get_python_example_snippet_override(start_id: str, rel_path: Path) -> list[str]: """Check if the snippet is overridden by a python example snippet.""" key = (os.fspath(rel_path), start_id) value = python_example_snippet_mapping().get(key) @@ -275,7 +275,7 @@ def get_python_example_snippet_override(start_id: str, rel_path: str) -> list[st return overriden_snippet_lines(lines, start_id) -def get_snippets(lines: list[str], rel_path: str) -> list[list[str]]: +def get_snippets(lines: list[str], rel_path: Path) -> list[list[str]]: """Extract (potentially overlapping) snippets from a C++ file indicated by '//! [1]'.""" result = _get_snippets(lines, '//', CPP_SNIPPET_PATTERN) @@ -288,7 +288,7 @@ def get_snippets(lines: list[str], rel_path: str) -> list[list[str]]: if snippet: result[snippet_id] = snippet - return result.values() + return list(result.values()) def get_license_from_file(lines): |