Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreachable code in python_completer.py #1672

Open
EmmaJaneBonestell opened this issue Jan 5, 2023 · 2 comments · May be fixed by #1715
Open

Unreachable code in python_completer.py #1672

EmmaJaneBonestell opened this issue Jan 5, 2023 · 2 comments · May be fixed by #1715

Comments

@EmmaJaneBonestell
Copy link

The last commit to ycmd/completers/python/python_completer.py ( 9e6b32b ) 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

responses.Range( *_OffsetToPosition( ( old_start, old_end ),
filename,
old_text,
newlines ) )
) )

PLW0101 Unreachable code, 656:3
if len( loc ) == 2:
break
return loc
# Invalid position - it's outside of the text. Just return the last
# position in the text. This is an internal error.
LOGGER.error( "Invalid offset %s in file %s with text %s and newlines %s",
offset,
filename,
text,
newlines )
raise RuntimeError( "Invalid file offset in diff" )

@puremourning
Copy link
Member

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

@EmmaJaneBonestell
Copy link
Author

@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

bstaletic added a commit to bstaletic/ycmd that referenced this issue Oct 7, 2023
After combing through all the stuff pylint has found, this seems to me
the useful part.

The only questionable thing here, I think, could be the stuff related to
`open()` and explicit encoding argument. This changes behaviour!
Without specifying, the encoding is platform dependent. See
https://docs.python.org/3/library/functions.html#open for details.

Fixes ycm-core#1672
bstaletic added a commit to bstaletic/ycmd that referenced this issue Oct 7, 2023
After combing through all the stuff pylint has found, this seems to me
the useful part.

The only questionable thing here, I think, could be the stuff related to
`open()` and explicit encoding argument. This changes behaviour!
Without specifying, the encoding is platform dependent. See
https://docs.python.org/3/library/functions.html#open for details.

Fixes ycm-core#1672
@bstaletic bstaletic linked a pull request Oct 7, 2023 that will close this issue
bstaletic added a commit to bstaletic/ycmd that referenced this issue Oct 7, 2023
After combing through all the stuff pylint has found, this seems to me
the useful part.

The only questionable thing here, I think, could be the stuff related to
`open()` and explicit encoding argument. This changes behaviour!
Without specifying, the encoding is platform dependent. See
https://docs.python.org/3/library/functions.html#open for details.

Fixes ycm-core#1672
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants