Dear readers, I have a pylint scoping (or how-to) question.
pylint 2.7.2 astroid 2.5.1 Python 3.9.2 (default, Feb 28 2021, 17:03:44) Objective: to disable all pylint errors/warnings starting from a particular source line until EOF (that part contains to-be-run-manually scratch/test code for that file) As an MWE consider this code: #----------------------------------------------- usr/bin/python3 """MWE""" print(does_not_exist_1) # Xpylint: disable=undefined-variable # Xpylint: disable=all print(does_not_exist_2) print(does_not_exist_3) #----------------------------------------------- Pylint docs say that disables are per-scope. Thusly a # pylint: disable=undefined-variable inside the file-global scope should (?) disable undefined-variable for the entire (?) file-global scope. It does not, however, but rather seems to disable it inside the file-global scope *from the line of occurrence onwards*. To see this, remove the X from the relevant disable in the MWE. This is the behaviour I desire to achieve. However, when using the "disable=all" it *does* disable all output, including the x.py:4:6: E0602: Undefined variable 'does_not_exist_1' (undefined-variable) despite the # pylint: disable=all sitting *after* the print(does_not_exist_1) So: Am I doing something wrong ? Am I misinterpreting the docs ? Do the docs explain this difference in disable-scoping ? How should I properly go about my objective (apart from fixing my code, of course :-D ) ? Thanks for insights, Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B -- https://mail.python.org/mailman/listinfo/python-list