Linter wishlist
A catch-all issue to report things that could/should be improved in Linter performance
Follow up from https://github.com/causify-ai/helpers/pull/262#issuecomment-2621616266
We encountered some formatting issues in the docstring of a function when the linter was run on the following file. This is non-blocking, as we can simply revert and ignore it, but linter might benefit from this improvement in the future.
FYI @dremdem @sonniki
Output from Linter
(client_venv.helpers) heanhs@dev1:~/src/helpers2$ i lint -f helpers/lib_tasks_gh.py
...
17:20:10 - INFO hdbg.py init_logger:1015 > cmd='./linters/base.py --files helpers/lib_tasks_gh.py'
17:20:11 - INFO base.py _run_linter:383 Using num_threads='serial' since there is only one file to lint
17:20:11 - INFO base.py _lint:348
Linting file: 'helpers/lib_tasks_gh.py'
17:20:13 - WARN amp_normalize_import.py _remove_import_from_docstring_text:855 The docstring must end with the import line: all comments after the import line will be removed.
////////////////////////////////////////////////////////////////////////////////
./linter_warnings.txt
////////////////////////////////////////////////////////////////////////////////
cmd line='./linters/base.py --files helpers/lib_tasks_gh.py'
file_paths=1 ['helpers/lib_tasks_gh.py']
actions=24 ['add_python_init_files', 'add_toc_to_notebook', 'fix_md_links', 'lint_md', 'check_md_toc_headers', 'autoflake', 'fix_whitespaces', 'doc_formatter', 'isort', 'class_method_order', 'normalize_imports', 'format_separating_line', 'add_class_frames', 'black', 'process_jupytext', 'check_file_size', 'check_filename', 'check_merge_conflict', 'check_import', 'warn_incorrectly_formatted_todo', 'check_md_reference', 'flake8', 'pylint', 'mypy']
////////////////////////////////////////////////////////////////////////////////
helpers/lib_tasks_gh.py:12: do not use 'from invoke import task' use 'import foo.bar as fba' [check_import]
helpers/lib_tasks_gh.py:192: [C0209(consider-using-f-string), gh_workflow_list] Formatting a regular string which could be an f-string [pylint]
helpers/lib_tasks_gh.py:226: [C0301(line-too-long), ] Line too long (138/100) [pylint]
helpers/lib_tasks_gh.py:227: [C0301(line-too-long), ] Line too long (138/100) [pylint]
helpers/lib_tasks_gh.py:228: [C0301(line-too-long), ] Line too long (138/100) [pylint]
helpers/lib_tasks_gh.py:230: [C0301(line-too-long), ] Line too long (123/100) [pylint]
helpers/lib_tasks_gh.py:236: [C0301(line-too-long), ] Line too long (109/100) [pylint]
helpers/lib_tasks_gh.py:393: [R0917(too-many-positional-arguments), gh_create_pr] Too many positional arguments (6/5) [pylint]
helpers/lib_tasks_gh.py:590: error: Name "pd" is not defined [name-defined] [mypy]
helpers/lib_tasks_gh.py:590:63: F821 undefined name 'pd' [flake8]
helpers/lib_tasks_gh.py:598: [C0301(line-too-long), ] Line too long (110/100) [pylint]
helpers/lib_tasks_gh.py:599: [C0301(line-too-long), ] Line too long (113/100) [pylint]
helpers/lib_tasks_gh.py:600: [C0301(line-too-long), ] Line too long (113/100) [pylint]
helpers/lib_tasks_gh.py:643: error: Unsupported target for indexed assignment ("dict[str, Any] | None") [index] [mypy]
helpers/lib_tasks_gh.py:654: error: Name "pd" is not defined [name-defined] [mypy]
helpers/lib_tasks_gh.py:654:14: F821 undefined name 'pd' [flake8]
helpers/lib_tasks_gh.py:670: [C0301(line-too-long), ] Line too long (122/100) [pylint]
helpers/lib_tasks_gh.py:703: [C0209(consider-using-f-string), gh_get_workflow_type_names] Formatting a regular string which could be an f-string [pylint]
helpers/lib_tasks_gh.py:746: [C0301(line-too-long), ] Line too long (172/100) [pylint]
helpers/lib_tasks_gh.py:764: error: Returning Any from function declared to return "list[dict[str, Any]]" [no-any-return] [mypy]
Before Linting
def _get_failed_or_successful_workflow_run(
workflow_runs: List[Dict[str, Any]]
) -> Optional[Dict[str, Any]]:
"""
Get the most recent successful or failed workflow run.
:param workflow_runs: list of workflow runs
:return: the most recent successful or failed workflow run or None if not
found, e.g.,
```
{
'conclusion': 'success',
'status': 'completed',
'url': 'https://github.com/cryptokaizen/cmamp/actions/runs/8714881296',
'workflowName': 'Allure fast tests'
}
```
"""
After Linting
"""
def _get_failed_or_successful_workflow_run(
workflow_runs: List[Dict[str, Any]]
) -> Optional[Dict[str, Any]]:
"""
Get the most recent successful or failed workflow run.
:param workflow_runs: list of workflow runs :return: the most recent
successful or failed workflow run or None if not found, e.g.,
``` { 'conclusion': 'success', 'status':
'completed', 'url':
'https://github.com/cryptokaizen/cmamp/actions/runs/8714881296',
:param workflow_runs: list of workflow runs
:return: the most recent successful or failed workflow run or None
if not found, e.g., ``` { 'conclusion': 'success', 'status':
'completed', 'url':
'https://github.com/cryptokaizen/cmamp/actions/runs/8714881296',
'workflowName': 'Allure fast tests' } ```
"""
We encountered some formatting issues in the docstring of a function when the linter was run on the following file. This is non-blocking, as we can simply revert and ignore it, but linter might benefit from this improvement in the future.
@heanhsok, fixed in #270, https://github.com/causify-ai/helpers/pull/272
I've filed a similar bug. Not sure if it's fixed already. In any case, let's file bugs, rather than catch all to make things more visible.
I've filed a similar bug. Not sure if it's fixed already. In any case, let's file bugs, rather than catch all to make things more visible.
It has indeed already been fixed. Please pull master/update the pointer to helpers to the latest state, to make sure you have the latest version of Linter. The idea behind the catch-all was exactly so that people could see if the same bug has already been reported (and possibly fixed), to avoid bug duplication.
Not very useful atm; closing