Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-flake8-debugger for openSUSE:Factory checked in at 2022-11-01 13:42:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-flake8-debugger (Old) and /work/SRC/openSUSE:Factory/.python-flake8-debugger.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-flake8-debugger" Tue Nov 1 13:42:08 2022 rev:4 rq:1032481 version:4.1.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-flake8-debugger/python-flake8-debugger.changes 2021-04-01 14:19:32.376174149 +0200 +++ /work/SRC/openSUSE:Factory/.python-flake8-debugger.new.2275/python-flake8-debugger.changes 2022-11-01 13:42:17.647808594 +0100 @@ -1,0 +2,13 @@ +Wed Oct 12 03:20:30 UTC 2022 - Yogalakshmi Arunachalam <yarunacha...@suse.com> + +- Update to version 4.1.2 + * Add tests to bundle. + +- Update to version 4.1.1 + * Add tests to bundle. + +- Update to version 4.1.0 + * Drop support for python 3.6 and remove special handling code. + * bundle licence file. + +------------------------------------------------------------------- Old: ---- flake8-debugger-4.0.0.tar.gz New: ---- flake8-debugger-4.1.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-flake8-debugger.spec ++++++ --- /var/tmp/diff_new_pack.OT5Sgx/_old 2022-11-01 13:42:18.111811063 +0100 +++ /var/tmp/diff_new_pack.OT5Sgx/_new 2022-11-01 13:42:18.115811084 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-flake8-debugger # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %global skip_python2 1 Name: python-flake8-debugger -Version: 4.0.0 +Version: 4.1.2 Release: 0 Summary: ipdb/pdb statement checker plugin for flake8 License: MIT ++++++ flake8-debugger-4.0.0.tar.gz -> flake8-debugger-4.1.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-debugger-4.0.0/LICENCE new/flake8-debugger-4.1.2/LICENCE --- old/flake8-debugger-4.0.0/LICENCE 1970-01-01 01:00:00.000000000 +0100 +++ new/flake8-debugger-4.1.2/LICENCE 2022-04-30 18:32:47.135803200 +0200 @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Joseph Kahn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-debugger-4.0.0/PKG-INFO new/flake8-debugger-4.1.2/PKG-INFO --- old/flake8-debugger-4.0.0/PKG-INFO 2020-11-29 15:34:40.869482000 +0100 +++ new/flake8-debugger-4.1.2/PKG-INFO 2022-04-30 18:50:47.868120000 +0200 @@ -1,13 +1,13 @@ Metadata-Version: 2.1 Name: flake8-debugger -Version: 4.0.0 +Version: 4.1.2 Summary: ipdb/pdb statement checker plugin for flake8 Home-page: https://github.com/jbkahn/flake8-debugger License: MIT Keywords: flake8,plugin,linting,debugger,ipdb,code quality Author: Joseph Kahn Author-email: josephbk...@gmail.com -Requires-Python: >=3.6 +Requires-Python: >=3.7 Classifier: Development Status :: 3 - Alpha Classifier: Environment :: Console Classifier: Framework :: Flake8 @@ -17,7 +17,6 @@ Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 @@ -25,7 +24,6 @@ Classifier: Topic :: Software Development :: Quality Assurance Requires-Dist: flake8 (>=3.0) Requires-Dist: pycodestyle -Requires-Dist: six Project-URL: Repository, https://github.com/jbkahn/flake8-debugger Description-Content-Type: text/markdown @@ -59,6 +57,19 @@ Changes ------- +##### 4.1.2 - 2022-04-30 + +* Add tests to bundle. + +##### 4.1.1 - 2022-04-30 + +* Add tests to bundle. + +##### 4.1.0 - 2022-04-30 + +* Drop support for python 3.6 and remove special handling code. +* bundle licence file. + ##### 4.0.0 - 2020-11-29 * Opted back into using Poetry now that the existing issues have been fixed. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-debugger-4.0.0/README.md new/flake8-debugger-4.1.2/README.md --- old/flake8-debugger-4.0.0/README.md 2020-11-29 15:34:24.106767200 +0100 +++ new/flake8-debugger-4.1.2/README.md 2022-04-30 18:47:22.242065200 +0200 @@ -28,6 +28,19 @@ Changes ------- +##### 4.1.2 - 2022-04-30 + +* Add tests to bundle. + +##### 4.1.1 - 2022-04-30 + +* Add tests to bundle. + +##### 4.1.0 - 2022-04-30 + +* Drop support for python 3.6 and remove special handling code. +* bundle licence file. + ##### 4.0.0 - 2020-11-29 * Opted back into using Poetry now that the existing issues have been fixed. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-debugger-4.0.0/flake8_debugger.py new/flake8-debugger-4.1.2/flake8_debugger.py --- old/flake8-debugger-4.0.0/flake8_debugger.py 2020-11-29 15:34:24.107055400 +0100 +++ new/flake8-debugger-4.1.2/flake8_debugger.py 2022-04-30 18:47:17.872095000 +0200 @@ -1,6 +1,5 @@ """Extension for flake8 that finds usage of the debugger.""" import ast -import sys from itertools import chain import pycodestyle @@ -10,7 +9,7 @@ except ImportError: from flake8 import utils as stdin_utils -__version__ = "4.0.0" +__version__ = "4.1.2" DEBUGGER_ERROR_CODE = "T100" @@ -20,11 +19,10 @@ "ipdb": ["set_trace", "sset_trace"], "IPython.terminal.embed": ["InteractiveShellEmbed"], "IPython.frontend.terminal.embed": ["InteractiveShellEmbed"], + "celery.contrib.rdb": ["set_trace"], + "builtins": ["breakpoint"] } -if sys.version_info >= (3, 7): - debuggers["builtins"] = ["breakpoint"] - class DebuggerFinder(ast.NodeVisitor): def __init__(self, *args, **kwargs): @@ -38,7 +36,7 @@ self.debuggers_imported = {} def visit_Call(self, node): - if sys.version_info >= (3, 7) and getattr(node.func, "id", None) == "breakpoint": + if getattr(node.func, "id", None) == "breakpoint": entry = self.debuggers_used.setdefault((node.lineno, node.col_offset), []) entry.append("{0} trace found: breakpoint used".format(DEBUGGER_ERROR_CODE)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-debugger-4.0.0/pyproject.toml new/flake8-debugger-4.1.2/pyproject.toml --- old/flake8-debugger-4.0.0/pyproject.toml 2020-11-29 15:34:24.107966200 +0100 +++ new/flake8-debugger-4.1.2/pyproject.toml 2022-04-30 18:49:10.991401000 +0200 @@ -4,7 +4,7 @@ [tool.poetry] name = "flake8-debugger" -version = "4.0.0" +version = "4.1.2" description = "ipdb/pdb statement checker plugin for flake8" readme = "README.md" @@ -40,24 +40,23 @@ ] -include = ["pyproject.toml", "flake8_debugger.py"] +include = ["pyproject.toml", "flake8_debugger.py", "LICENCE", "test_linter.py"] [tool.poetry.plugins."flake8.extension"] T100 = "flake8_debugger:DebuggerChecker" [tool.poetry.dependencies] -python = ">=3.6" +python = ">=3.7" "flake8" = ">=3.0" -six = "*" pycodestyle = "*" [tool.poetry.dev-dependencies] -black = { version = "^20.8b1" } +black = { version = "^22.3.0" } pytest = "*" [tool.black] line-length = 120 -target-version = ['py36', 'py37', 'py38', 'py39'] +target-version = ['py37', 'py38', 'py39', 'py310'] include = '\.pyi?$' exclude = ''' /( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-debugger-4.0.0/setup.py new/flake8-debugger-4.1.2/setup.py --- old/flake8-debugger-4.0.0/setup.py 2020-11-29 15:34:40.869191000 +0100 +++ new/flake8-debugger-4.1.2/setup.py 2022-04-30 18:50:47.867723000 +0200 @@ -4,16 +4,16 @@ modules = \ ['flake8_debugger'] install_requires = \ -['flake8>=3.0', 'pycodestyle', 'six'] +['flake8>=3.0', 'pycodestyle'] entry_points = \ {'flake8.extension': ['T100 = flake8_debugger:DebuggerChecker']} setup_kwargs = { 'name': 'flake8-debugger', - 'version': '4.0.0', + 'version': '4.1.2', 'description': 'ipdb/pdb statement checker plugin for flake8', - 'long_description': 'Flake8 debugger plugin\n======================\n\nCheck for pdb;idbp imports and set traces, as well as `from IPython.terminal.embed import InteractiveShellEmbed` and `InteractiveShellEmbed()()`.\n\nThis module provides a plugin for ``flake8``, the Python code checker.\n\n\nInstallation\n------------\n\nYou can install or upgrade ``flake8-debugger`` with these commands::\n\n $ pip install flake8-debugger\n $ pip install --upgrade flake8-debugger\n\n\nPlugin for Flake8\n-----------------\n\nWhen both ``flake8 2.2`` and ``flake8-debugger`` are installed, the plugin is\navailable in ``flake8``::\n\n $ flake8 --version\n 2.0 (pep8: 1.4.5, flake8-debugger: 1.0, pyflakes: 0.6.1)\n\n\nChanges\n-------\n\n##### 4.0.0 - 2020-11-29\n\n* Opted back into using Poetry now that the existing issues have been fixed.\n* Python 2.7 support was no officially dropped.\n\n##### 3.2.1 - 2019-10-31\n\n* Swapped back from poetry to setup.py :(....python ecosystem issues ....\n\n##### 3.2.0 - 2019-10-15\n\n* Forgot to add `breakpoint` support to the last changelog entry as well as fixing a bug introduced into that version that flagged `import builtins` as noteworthy.\n\n\n##### 3.1.1 - 2019-10-12\n\n* Fix reading from stdin when it is closed (requires flake8 > 2.1).\n* Swapped to poetry from setup.py\n* Ran black on the repository\n\n##### 3.1.0 - 2018-02-11\n* Add a framework classifier for use in pypi.org\n* Fix entry_point in setup.py leaving it off by default again\n* Detect __import__ debugger statements\n* Add support for `pudb` detection\n\n##### 3.0.0 - 2017-05-11\n* fix the refactor of the detector in 2.0.0 that was removed from pypi.\n* fix a flake8 issue that had it turned off by default.\n\n\n##### 2.0.0 - 2016-09-19\n* refactor detector\n* drop official support for python 2.6 and 3.3\n\n\n##### 1.4.0 - 2015-05-18\n* refactor detector, run tests in python 2.6, 2.7 and 3.4 as well as adding a check for InteractiveShellEmbed.\n\n##### 1.3. 2 - 2014-11-04\n* more tests, fix edge case and debugger identification.\n\n##### 1.3.1 - 2014-11-04\n* more tests, a little refactoring and improvements in catching.\n\n##### 1.3 - 2014-11-04\n* using ast instead of regular expressions\n\n##### 1.2 - 2014-06-30\n* Added a few simple tests\n\n##### 1.1 - 2014-06-30\n* First release\n\n##### 1.0 - 2014-06-30\n* Whoops\n', + 'long_description': 'Flake8 debugger plugin\n======================\n\nCheck for pdb;idbp imports and set traces, as well as `from IPython.terminal.embed import InteractiveShellEmbed` and `InteractiveShellEmbed()()`.\n\nThis module provides a plugin for ``flake8``, the Python code checker.\n\n\nInstallation\n------------\n\nYou can install or upgrade ``flake8-debugger`` with these commands::\n\n $ pip install flake8-debugger\n $ pip install --upgrade flake8-debugger\n\n\nPlugin for Flake8\n-----------------\n\nWhen both ``flake8 2.2`` and ``flake8-debugger`` are installed, the plugin is\navailable in ``flake8``::\n\n $ flake8 --version\n 2.0 (pep8: 1.4.5, flake8-debugger: 1.0, pyflakes: 0.6.1)\n\n\nChanges\n-------\n\n##### 4.1.2 - 2022-04-30\n\n* Add tests to bundle.\n\n##### 4.1.1 - 2022-04-30\n\n* Add tests to bundle.\n\n##### 4.1.0 - 2022-04-30\n\n* Drop support for python 3.6 and remove special handling code.\n* bundle licence file.\n\n##### 4.0.0 - 2020-11-29\n \n* Opted back into using Poetry now that the existing issues have been fixed.\n* Python 2.7 support was no officially dropped.\n\n##### 3.2.1 - 2019-10-31\n\n* Swapped back from poetry to setup.py :(....python ecosystem issues....\n\n##### 3.2.0 - 2019-10-15\n\n* Forgot to add `breakpoint` support to the last changelog entry as well as fixing a bug introduced into that version that flagged `import builtins` as noteworthy.\n\n\n##### 3.1.1 - 2019-10-12\n\n* Fix reading from stdin when it is closed (requires flake8 > 2.1).\n* Swapped to poetry from setup.py\n* Ran black on the repository\n\n##### 3.1.0 - 2018-02-11\n* Add a framework classifier for use in pypi.org\n* Fix entry_point in setup.py leaving it off by default again\n* Detect __import__ debugger statements\n* Add support for `pudb` detection\n\n##### 3.0.0 - 2017-05-11\n* fix the refactor of the detector in 2.0.0 that was removed from pypi.\n* fix a flake8 issue that had it turned off by default.\n\n\n##### 2.0.0 - 2016-09- 19\n* refactor detector\n* drop official support for python 2.6 and 3.3\n\n\n##### 1.4.0 - 2015-05-18\n* refactor detector, run tests in python 2.6, 2.7 and 3.4 as well as adding a check for InteractiveShellEmbed.\n\n##### 1.3.2 - 2014-11-04\n* more tests, fix edge case and debugger identification.\n\n##### 1.3.1 - 2014-11-04\n* more tests, a little refactoring and improvements in catching.\n\n##### 1.3 - 2014-11-04\n* using ast instead of regular expressions\n\n##### 1.2 - 2014-06-30\n* Added a few simple tests\n\n##### 1.1 - 2014-06-30\n* First release\n\n##### 1.0 - 2014-06-30\n* Whoops\n', 'author': 'Joseph Kahn', 'author_email': 'josephbk...@gmail.com', 'maintainer': None, @@ -22,7 +22,7 @@ 'py_modules': modules, 'install_requires': install_requires, 'entry_points': entry_points, - 'python_requires': '>=3.6', + 'python_requires': '>=3.7', } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-debugger-4.0.0/test_linter.py new/flake8-debugger-4.1.2/test_linter.py --- old/flake8-debugger-4.0.0/test_linter.py 1970-01-01 01:00:00.000000000 +0100 +++ new/flake8-debugger-4.1.2/test_linter.py 2022-04-30 18:32:47.137562000 +0200 @@ -0,0 +1,415 @@ +import pycodestyle + +from flake8_debugger import DebuggerChecker + +import pytest + + +class CaptureReport(pycodestyle.BaseReport): + """Collect the results of the checks.""" + + def __init__(self, options): + self._results = [] + super(CaptureReport, self).__init__(options) + + def error(self, line_number, offset, text, check): + """Store each error.""" + code = super(CaptureReport, self).error(line_number, offset, text, check) + if code: + record = {"line": line_number, "col": offset, "message": "{0} {1}".format(code, text[5:])} + self._results.append(record) + return code + + +class DebuggerTestStyleGuide(pycodestyle.StyleGuide): + + logical_checks = [] + physical_checks = [] + ast_checks = [("debugger_usage", DebuggerChecker, ["tree", "filename", "lines"])] + max_line_length = None + max_doc_length = None + hang_closing = False + verbose = False + benchmark_keys = {"files": 0, "physical lines": 0, "logical lines": 0} + indent_size = 4 + + +_debugger_test_style = DebuggerTestStyleGuide() + + +def check_code_for_debugger_statements(code): + """Process code using pycodestyle Checker and return all errors.""" + from tempfile import NamedTemporaryFile + + test_file = NamedTemporaryFile(delete=False) + test_file.write(code.encode()) + test_file.flush() + report = CaptureReport(options=_debugger_test_style) + lines = [line + "\n" for line in code.split("\n")] + checker = pycodestyle.Checker(filename=test_file.name, lines=lines, options=_debugger_test_style, report=report) + + checker.check_all() + return report._results + + +class TestQA(object): + def test_catches_simple_debugger(self): + result = check_code_for_debugger_statements("from ipdb import set_trace as r\nr()") + + expected_result = [ + {"line": 2, "message": "T100 trace found: set_trace used as r", "col": 0}, + {"line": 1, "message": "T100 import for set_trace found as r", "col": 0}, + ] + + assert result == expected_result + + def test_catches_simple_debugger_when_called_off_lib(self): + result = check_code_for_debugger_statements("import ipdb\nipdb.set_trace()") + + expected_result = [ + {"line": 2, "message": "T100 trace found: ipdb.set_trace used", "col": 0}, + {"line": 1, "message": "T100 import for ipdb found", "col": 0}, + ] + + assert result == expected_result + + def test_catches_simple_debugger_when_called_off_global(self): + result = check_code_for_debugger_statements("__import__('ipdb').set_trace()") + + expected_result = [{"line": 1, "message": "T100 trace found: set_trace used", "col": 0}] + + assert result == expected_result + + @pytest.mark.skipif(True, reason="Not supported just yet") + def test_catches_simple_debugger_when_called_off_var(self): + result = check_code_for_debugger_statements("import ipdb\ntest = ipdb.set_trace\ntest()") + + expected_result = [ + {"line": 1, "message": "T100 import for ipdb found", "col": 0}, + {"line": 3, "message": "T100 trace found: ipdb.set_trace used", "col": 0}, + ] + assert result == expected_result + + +class TestBreakpoint(object): + def test_catches_breakpoint_call_for_python_3_7_and_above(self): + result = check_code_for_debugger_statements("breakpoint()") + + expected_result = [{"line": 1, "message": "T100 trace found: breakpoint used", "col": 0}] + + assert result == expected_result + + def test_catches_breakpoint_import(self): + result = check_code_for_debugger_statements("from builtins import breakpoint") + + expected_result = [{"line": 1, "message": "T100 import for breakpoint found", "col": 0}] + + assert result == expected_result + + def test_allows_builtins_import(self): + result = check_code_for_debugger_statements("import builtins") + + expected_result = [] + + assert result == expected_result + + def test_catches_breakpoint_usage_from_builtins(self): + result = check_code_for_debugger_statements("import builtins\nbuiltins.breakpoint()") + + expected_result = [{"col": 0, "line": 2, "message": "T100 trace found: breakpoint used"}] + + assert result == expected_result + + def test_catches_breakpoint_imported_as_other_name(self): + result = check_code_for_debugger_statements("from builtins import breakpoint as b\nb()") + + expected_result = [ + {"line": 2, "message": "T100 trace found: breakpoint used as b", "col": 0}, + {"line": 1, "message": "T100 import for breakpoint found as b", "col": 0}, + ] + + assert result == expected_result + + +class TestNoQA(object): + def test_skip_import(self): + result = check_code_for_debugger_statements("from ipdb import set_trace as r # noqa\nr()") + + expected_result = [{"line": 2, "message": "T100 trace found: set_trace used as r", "col": 0}] + + assert result == expected_result + + def test_skip_usage(self): + result = check_code_for_debugger_statements("from ipdb import set_trace as r\nr() # noqa") + + expected_result = [{"line": 1, "message": "T100 import for set_trace found as r", "col": 0}] + + assert result == expected_result + + def test_skip_import_and_usage(self): + result = check_code_for_debugger_statements("from ipdb import set_trace as r # noqa\nr() # noqa") + + expected_result = [] + + assert result == expected_result + + +class TestImportCases(object): + def test_import_multiple(self): + result = check_code_for_debugger_statements("import math, ipdb, collections") + assert result == [{"col": 0, "line": 1, "message": "T100 import for ipdb found"}] + + def test_import(self): + result = check_code_for_debugger_statements("import pdb") + assert result == [{"col": 0, "line": 1, "message": "T100 import for pdb found"}] + + def test_import_interactive_shell_embed(self): + result = check_code_for_debugger_statements("from IPython.terminal.embed import InteractiveShellEmbed") + assert result == [{"col": 0, "line": 1, "message": "T100 import for InteractiveShellEmbed found"}] + + def test_import_both_same_line(self): + result = check_code_for_debugger_statements("import pdb, ipdb") + result = sorted(result, key=lambda debugger: debugger["message"]) + expected_result = [ + {"col": 0, "line": 1, "message": "T100 import for ipdb found"}, + {"col": 0, "line": 1, "message": "T100 import for pdb found"}, + ] + assert result == expected_result + + def test_import_math(self): + result = check_code_for_debugger_statements("import math") + assert result == [] + + def test_import_noqa(self): + result = check_code_for_debugger_statements("import ipdb # noqa") + assert result == [] + + +class TestModuleSetTraceCases(object): + def test_import_ipython_terminal_embed_use_InteractiveShellEmbed(self): + result = check_code_for_debugger_statements( + "from IPython.terminal.embed import InteractiveShellEmbed; InteractiveShellEmbed()()" + ) + + expected_result = [ + {"col": 58, "line": 1, "message": "T100 trace found: InteractiveShellEmbed used"}, + {"col": 0, "line": 1, "message": "T100 import for InteractiveShellEmbed found"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + def test_import_ipdb_use_set_trace(self): + result = check_code_for_debugger_statements("import ipdb;ipdb.set_trace();") + + expected_result = [ + {"col": 12, "line": 1, "message": "T100 trace found: ipdb.set_trace used"}, + {"col": 0, "line": 1, "message": "T100 import for ipdb found"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + def test_import_pdb_use_set_trace(self): + result = check_code_for_debugger_statements("import pdb;pdb.set_trace();") + + expected_result = [ + {"col": 11, "line": 1, "message": "T100 trace found: pdb.set_trace used"}, + {"col": 0, "line": 1, "message": "T100 import for pdb found"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + def test_import_pdb_use_set_trace_twice(self): + result = check_code_for_debugger_statements("import pdb;pdb.set_trace() and pdb.set_trace();") + + expected_result = [ + {"col": 11, "line": 1, "message": "T100 trace found: pdb.set_trace used"}, + {"col": 31, "line": 1, "message": "T100 trace found: pdb.set_trace used"}, + {"col": 0, "line": 1, "message": "T100 import for pdb found"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + def test_import_other_module_as_set_trace_and_use_it(self): + result = check_code_for_debugger_statements("from math import Max as set_trace\nset_trace()") + assert result == [] + + def test_import_rdb_use_set_trace(self): + result = check_code_for_debugger_statements("from celery.contrib import rdb;rdb.set_trace();") + + expected_result = [ + {"col": 31, "line": 1, "message": "T100 trace found: set_trace used"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + def test_from_celery_import_rdb_use_set_trace(self): + result = check_code_for_debugger_statements("import celery.contrib.rdb;celery.contrib.rdb.set_trace();") + + expected_result = [ + {"col": 26, "line": 1, "message": "T100 trace found: set_trace used"}, + {"col": 0, "line": 1, "message": "T100 import for celery.contrib.rdb found"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + +class TestImportAsCases(object): + def test_import_ipdb_as(self): + result = check_code_for_debugger_statements("import math, ipdb as sif, collections") + assert result == [{"col": 0, "line": 1, "message": "T100 import for ipdb found as sif"}] + + +class TestModuleASSetTraceCases(object): + def test_import_ipdb_as_use_set_trace(self): + result = check_code_for_debugger_statements("import ipdb as sif;sif.set_trace();") + + expected_result = [ + {"col": 19, "line": 1, "message": "T100 trace found: sif.set_trace used"}, + {"col": 0, "line": 1, "message": "T100 import for ipdb found as sif"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + +class TestImportSetTraceCases(object): + def test_import_set_trace_ipdb(self): + result = check_code_for_debugger_statements("from ipdb import run, set_trace;set_trace();") + + expected_result = [ + {"col": 32, "line": 1, "message": "T100 trace found: set_trace used"}, + {"col": 0, "line": 1, "message": "T100 import for set_trace found"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + def test_import_set_trace_pdb(self): + result = check_code_for_debugger_statements("from pdb import set_trace; set_trace();") + + expected_result = [ + {"col": 27, "line": 1, "message": "T100 trace found: set_trace used"}, + {"col": 0, "line": 1, "message": "T100 import for set_trace found"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + def test_import_set_trace_ipdb_as_and_use(self): + result = check_code_for_debugger_statements("from ipdb import run, set_trace as sif; sif();") + + expected_result = [ + {"col": 40, "line": 1, "message": "T100 trace found: set_trace used as sif"}, + {"col": 0, "line": 1, "message": "T100 import for set_trace found as sif"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + def test_import_set_trace_ipdb_as_and_use_with_conjunction_and(self): + result = check_code_for_debugger_statements("from ipdb import run, set_trace as sif; True and sif();") + + expected_result = [ + {"col": 49, "line": 1, "message": "T100 trace found: set_trace used as sif"}, + {"col": 0, "line": 1, "message": "T100 import for set_trace found as sif"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + def test_import_set_trace_ipdb_as_and_use_with_conjunction_or(self): + result = check_code_for_debugger_statements("from ipdb import run, set_trace as sif; True or sif();") + + expected_result = [ + {"col": 48, "line": 1, "message": "T100 trace found: set_trace used as sif"}, + {"col": 0, "line": 1, "message": "T100 import for set_trace found as sif"}, + ] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result + + def test_import_set_trace_ipdb_as_and_use_with_conjunction_or_noqa(self): + result = check_code_for_debugger_statements("from ipdb import run, set_trace as sif; True or sif(); # noqa") + try: + assert result == [] + except AssertionError: + pass + + def test_import_set_trace_ipdb_as_and_use_with_conjunction_or_noqa_import_only(self): + result = check_code_for_debugger_statements("from ipdb import run, set_trace as sif # noqa\nTrue or sif()") + + expected_result = [{"col": 8, "line": 2, "message": "T100 trace found: set_trace used as sif"}] + + try: + assert result == expected_result + except AssertionError: + for item in expected_result: + item["col"] = 0 + + assert result == expected_result