Python-ta

Latest version: v2.8.1

Safety actively analyzes 682404 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 6

2.6.0

✨ Enhancements

- Can now create control flow graphs using `python_ta.control_flow_graphs` to visualize the
execution paths of Python code.
- `forbidden-top-level-code` and `forbidden-global-variables` now allow top-level type alias
assignment statements.
- The `trailing-whitespace` error message now highlights the trailing whitespace.
- The `unnecessary-indexing` error now checks for a greater variety of loop/comprehension indexes.
- Provided configuration files are now merged with PythonTA defaults, so you now only
need to specify options that you want to be overridden. To ignore PythonTA defaults (the
old behaviour), pass `load_default_config=False` to `check_errors` and `check_all`.
- Improved the code snippets for the `pep8-errors` "blank line" messages.
Extra blank lines are now highlighted, and suggestions are added when blank lines are missing.
- The default value of the `pyta-number-of-messages` configuration option is now 0 (changed from 5).
This causes all error occurrences to be displayed.
- Improved efficiency of the contract-checking custom `setattr` for classes.
- Added new function `python_ta.contracts.validate_invariants` to manually check contracts
for an object.
- Updated to [pycodestyle v2.11](https://github.com/PyCQA/pycodestyle/blob/main/CHANGES.txt).

🐛 Bug fixes

- Fixed bug where running `python3 -m python_ta --generate-config` yields a `FileNotFoundError`.
- Fixed bug in how PythonTA reports error messages that occur when parsing configuration files.
- Ensured some config file parsing errors no longer display incorrect lines in the error report.
- Fixed bug where the `HTMLReporter` and `JSONReporter` would ignore the `pyta-number-of-messages`
option and always display all error occurrences.
- Fixed bug in `check_contracts` where imported classes were not correctly resolved when checking
types.
- Fixed bug for class contract-checking when assigning an instance attribute that violates a class
type constraint or representation invariant. Previously, the instance attribute changed to the
new value after the error was raised, but now is correctly restored to the original value.
- Remove line double-spacing in PlainReporter and ColorReporter output code snippets.

💫 New checkers

Custom checkers:

- `invalid-name-checker`: Provide beginner-friendly error messages when reporting variable names
that violate Python naming conventions. This replaces pylint's
[C0103](https://pylint.pycqa.org/en/latest/user_guide/messages/convention/invalid-name.html)
check.

2.5.0

🐛 Bug fixes

- Fixed bug in possibly-undefined checker where a comprehension variable is falsely flagged as possibly undefined.
- Fixed bug where `check_errors` and `check_all` opens a webpage when a nonexistent or unreadable path is passed as an argument.
- Fixed the CFG implementation to resolve a bug in the possibly-undefined checker where variables were falsely flagged as possibly undefined when the code conditionally raises an exception and the variable was referenced afterwards.
- Fixed bug where the generated CFGs will highlight the except block as unreachable if the same exception it is handling was raised in the body of the tryexcept.

💫 New checkers

Custom checkers:

- `forbidden-python-syntax`: Flag code that is not permitted to be used on an assessment.

🔧 Internal changes

- Pin dependency versions

2.4.2

🐛 Bug fixes

- Fixed custom message formats based on Pylint 2.15 updates.
- Fixed bug in shadowing-in-comprehension checker when target is a subscript node.
- Ensured `check_contracts` and `check_all_contracts` do nothing when `ENABLE_CONTRACT_CHECKING` is `False`.

2.4.1

🐛 Bug fixes

- Fixed PyTA contract checking for method calls when running modules in PyCharm using the "Run File in Python Console" action.

2.4.0

✨ Enhancements

- `unnecessary_indexing_checker` has now been extended to check comprehensions in addition to for loops.
- `invalid_for_target_checker` has now been extended to check comprehensions in addition to for loops.
- `forbidden_io_function_checker` is now able to check for calls to IO functions written at the top-level of a module, but outside the main block.
- `python_ta.debug.AccumulationTable` is extended to support printing loop iterations for while loops.
- Violated representation invariant error message now includes the class name and current values of the instance attributes.
- Added constant `python_ta.contracts.ENABLE_CONTRACT_CHECKING` to only check contracts when its value is set to `True`.
- `python_ta.debug.AccumulationTable` has extended loop detection to allow the loop to appear anywhere inside the with statement.

🐛 Bug fixes

- Fixed Issue 831: Contract Checker Bug. Now raises `AssertionError` when the expected type is `float` but got `int` instead.
- PyTA contracts' type checking now raises `AssertionError` when the expected type is `int` but got `bool` instead.
- Fixed PyTA contract checking when running modules in PyCharm using the "Run File in Python Console" action.

💫 New checkers

Custom checkers:

- `forbidden-top-level-code`: Flag code written at the top level when it is not one of the four acceptable types.

2.3.3

🐛 Bug fixes

- Restored 'line_end', 'column_end', and 'snippet' fields in JSON reporter output.

Page 4 of 6

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.