ycm-core / ycmd

A code-completion & code-comprehension server
https://ycm-core.github.io/ycmd/
GNU General Public License v3.0
1.7k stars 766 forks source link

Unreachable code in python_completer.py #1672

Open EmmaJaneBonestell opened 1 year ago

EmmaJaneBonestell commented 1 year ago

The last commit to ycmd/completers/python/python_completer.py ( 9e6b32ba8a90563a53e998d5258b4214b48aec39 ) introduced several warnings and caused LOGGER.error to become unreachable/dead code.

E1120 No value for argument 'start' in constructor call, 621:9 E1120 No value for argument 'end' in constructor call, 621:9 https://github.com/ycm-core/ycmd/blob/f53e7acf511748dd50f733c11b7de93416410c17/ycmd/completers/python/python_completer.py#L621-L625 PLW0101 Unreachable code, 656:3 https://github.com/ycm-core/ycmd/blob/f53e7acf511748dd50f733c11b7de93416410c17/ycmd/completers/python/python_completer.py#L650-L661

puremourning commented 1 year ago

thanks. what is reporting these errors? I'm surprised our flake8 isn't reporting them

EmmaJaneBonestell commented 1 year ago

@puremourning Pylint, through Pylama. It reported quite a few other non-style warnings, false positives at a cursory glance, but they may be more meaningful to you. Pylint can also sometimes check python code that's using native extensions if you use 'unsafe-load-any-extension=yes'.

If you're interested this is the pylama.ini I used / pylint disables for style issues
``` [pylama] skip = */testdata/*,*/.coverage/*,*/.eggs/*,*/.env/*,*/.git/*,*/*.pyc,*/__pycache__/*, */.pytest_cache/*,*/.tox/*,*/.venv/*,.coverage/*,__pycache__/*,.pytest_cache/*, testdata/*,tests/* linters = pyflakes,pylint,vulture max-line-length = 80 [pylama:pyflakes] ignore = B006,B009,BLK100, C901, E111,E114,E121,E125,E126,E127,E128,E129,E131,E133,E201,E202,E203,E221,E222,E241,E251,E261,E301,E303,E402, R501,R502,R503,R504,R505,R506,R507,R508, TMA001, W501,W504 [pylint:vulture] sort-by-size = 1 [pylama:pylint] indent-string=' ' unsafe-load-any-extension=yes disable = C0103,C0114,C0114,C0115,C0116,C0302,C0325,C0411,C0412,C0413,C0415, E0012,E1101, I1101, R0902,R0903,R0904,R0913,R0914,R0915,R0916,R1702,R1705,R1710,R1720,R1723,R1724,R1725, W0107,W0201,W0212,W0235,W0237,W0603,W1203,W1406 # C0103 invalid-name, C0114 missing-module-docstring, C0115 missing-class-docstring # C0116 missing-function-docstring, C0302 too-many-lines, C0325 superfluous-parens # C0411 wrong-import-order, C0412 ungrouped-imports, C0413 wrong-import-position # C0415 import-outside-toplevel # E1101 no-member: can have false positives from unloaded/optional extensions # I1101 c-extension-no-member: Ibid. # R0902 too-many-instance-attributes, R0903 too-few-public-methods, R0904 too-many-public-methods # R0913 too-many-arguments, R0914 too-many-locals, R0915 too-many-statements # R0916 too-many-boolean-expressions, R1702 too-many-nested-blocks, R1705 no-else-return # R1710 inconsistent-return-statements, R1720 no-else-raise, R1723 no-else-break # R1724 no-else-continue, R1725 super-with-arguments # W0107 unnecessary-pass, W0201 attribute-defined-outside-init # W0212 protected-access: accessing a variable starting with _ # W0235 useless-super-delegation # W0237 arguments-renamed: argument name differs in method implementation / overridden method # W0603 global-variable, W1203 logging-fstring-interpolation, W1406 redundant-u-string-prefix ```