Skip to content

Releases: pyta-uoft/pyta

[2.9.1] 2024-12-09

10 Dec 02:36
Compare
Choose a tag to compare

🐛 Bug fixes

  • Added python_ta/debug/webstepper to project MANIFEST.in

[2.9.0] 2024-12-09

09 Dec 20:55
Compare
Choose a tag to compare

✨ Enhancements

  • Added include_frames filter to snapshot
  • Added exclude_frames filter to snapshot
  • Added exclude_vars filter to snapshot
  • Added new python_ta.debug module with an SnapshotTracer context manager for generating memory models
  • Added z3 option to inconsistent-or-missing-returns, redundant-assignment, and possibly-undefined checkers to only check for feasible code blocks based on edge z3 constraints
  • Included the name of redundant variable in E9959 redundant-assignment message
  • Update to pylint v3.3 and and astroid v3.3. This added support for Python 3.13 and dropped support for Python 3.8. (No new checkers are enabled by default.)
  • Added a STRICT_NUMERIC_TYPES configuration to python_ta.contracts allowing to enable/disable stricter type checking of numeric types
  • Added integration with MemoryViz Webstepper
  • Added z3 option to one-iteration-checker to only check for feasible code blocks based on edge z3 constraints
  • Added reporting for errors raised by custom transforms (Z3Visitor, CFGVisitor)
  • Ensured SnapshotTracer does not include the _trace_func stack frame
  • Enabled SnapshotTracer to create its output_directory argument if it doesn't already exist
  • Changed SnapshotTracer's Webstepper code line number to align with the source code line number

💫 New checkers

  • unmentioned-parameter: Provide error message when a function parameter is not mentioned by name in the function's docstring. By default, this checker is disabled.

🐛 Bug fixes

  • Fixed issue where snapshot errors on unserializable values
  • Fixed issue within Snapshot.py where the memory_viz_version parameter was not respected
  • Fixed issue where parallel assignment statements and assignment to multiple targets were not checked by redundant_assignment_checker
  • Fixed issue where annotated assignment statements were not checked by redundant_assignment_checker
  • Fixed issue where empty preconditions were preventing CFGs from being generated
  • Added strict numeric type checking to enforce type distinctions across the entire numeric hierarchy, including complex numbers.
  • Added strict type checking support for nested and union types (e.g., list[int], dict[float, int], Union[int, float])
  • Fixed issue where CFG edges from loop body to loop condition block was ignored during augmenting edge z3 constraints
  • Fixed issue in one-iteration-checker where the message was not correctly reported for while loops when z3 option is on
  • Fixed crash when z3-solver is not installed
  • Fixed crash when an inline comment had no spaces after the #

🔧 Internal changes

  • Renamed ExprWrapper class to Z3Parser
  • Renamed ExprWrapper module to z3_parser and moved it to new directory python_ta.z3
  • Removed node attribute for Z3Parser
  • Renamed reduce method of Z3Parser to parse
  • Renamed test_expr_wrapper to test_z3_parser
  • Added is_feasible attribute for CFGEdge and implemented update to edge feasibility based on lists of Z3 constraints
  • Refactored codebase to use modern type annotations. Replaced List with list, Dict with dict, Set with set, and Tuple with tuple
  • Checked for variable reassignment in AugAssign and AnnAssign node in parsing edge Z3 constraints
  • Rendered logically infeasible control flow graph edges in light grey
  • Modified test_snapshot_to_json_sets_primitive for Python 3.8 compatibility
  • Added unit tests for one_iteration_checker
  • Added mock webbrowser.open in tests to prevent browser tabs and HTTP requests during python_ta.check_all() executions.
  • Added pytest-mock as a development dependency
  • Make test_snapshot.py::test_snapshot_serializes_unserializable_value able to run on Windows.
  • Added GitHub Action workflow for automatically publishing releases to PyPI
  • Update SnapshotTracer tests to use memory-viz@0.5.0 and prevent browser from opening
  • Updated bundled webstepper version and removed source map, and excluded the bundle from prettier pre-commit check

[2.8.1] 2024-08-19

20 Aug 03:24
Compare
Choose a tag to compare

🐛 Bug fixes

  • Fix loading of setendings plugin when z3-solver is not installed

[2.8.0] 2024-08-19

20 Aug 03:23
Compare
Choose a tag to compare

WARNING: this release assumes that the z3-solver Python library is installed. Users are strongly encouraged to install v2.8.1 instead.

✨ Enhancements

  • Add new boolean configuration allow-local-imports to allow for local imports
  • Extended the snasphot function to include the relevant variables defined at the top level (global variables).
  • Include the pycodestyle error code to the error message for PEP8 style errors
  • Added date and time display to PlainReporter and ColorReporter
  • Allowed specifying allowed names in configurations allowed-import-modules and extra-imports instead of just modules
  • Improved error display for pycodestyle (E9989) errors E123, E203, E222, E226, and E262
  • Added the configuration option to ignore naming convention violations (C9103 and C9104) for names matching the provided regular expression.
  • Update to pylint v3.1 and and astroid v3.1
  • Stored actual AST condition node in edges leading out of If/While blocks in generated control flow graphs.
  • Stored valid Python function preconditions in initial edge to function code in generated function control flow graphs.
  • Report warning when control flow graph creation encounters a syntax error related to control flow
  • Added autoformat option that runs black formatting tool to python_ta.check_all()
  • Extended the snapshot function to optionally generate a svg of the snapshot using MemoryViz when save parameter is true.

💫 New checkers

Pylint checkers v3.1:

  • use-yield-from
  • deprecated-attribute

For more information on these checkers, please see the
Pylint release notes. Note that the above
list only contains the Pylint checkers enabled by default in PythonTA.

Custom checkers:

  • inconsistent-returns and missing-return-statement: Provide clearer error messages when reporting missing return statements. This replaces pylint's R1710 check.

🐛 Bug fixes

  • Fixed issue with error message of C0410 by reformating it to properly fit with the list of modules imported that are provided to it
  • Fixed bug where _ was marked as a built-in when running PythonTA after running doctest
  • Fixed issue where annotated constant variable assignment was not considered as permissible top level code and triggered error E9992
  • Fixed issue where top level class attribute assignment was considered as permissible top level code
  • Fixed issue where check_contracts fails silently when function preconditions contain precondition violations, and when a representation invariant contains a call to a top-level function (not built-in or imported library).
  • Fixed issue where methods called in representation invariants lead to infinite recursion.
  • Fixed issue where PossiblyUndefinedChecker raised an error if the control flow graph was invalid due to syntax error

🔧 Internal changes

  • Updated changelog and pull request template formats
  • Added unit tests for PEP8 errors E115, E122, E125, E127, E129, E131 for PycodestyleChecker
  • Added unit tests for PEP8 errors E223, E224, E227, E228, E265 for PycodestyleChecker
  • Refactored test_check_on_dir in test_check.py module to test on sample_dir, a subset of examples
  • Added unit test test_examples_files_pyta in test_examples.py to check every file in examples with PythonTA
  • Added unit tests for PEP8 errors E266, E275, E301, E303, E304 for PycodestyleChecker
  • Moved tests related to __main__.py from test_check.py to test_main.py
  • Added more unit tests to test_main.py to increase coverage of __main__.py to 100%
  • Updated README.md to reflect updated folder structure
  • Added unit test test_pycodestyle_errors_pyta in test_examples.py to check every file in e9989_pycodestyle with PythonTA for PEP8 errors
  • Parametrized tests for PycodestyleChecker
  • Moved tests related to snapshot.py out of test_accumulation_table.py and into new module test_snapshot.py
  • Updated GitHub Action tests to avoid running test_accumulation_table.py and test_recursion_table.py with coverage and add verbose output for debug testing
  • Allowed GitHub Action tests to run on all pull requests, including drafts
  • Updated dependencies for GitHub Actions to use the latest versions
  • Updated dependabot configuration to auto-update dependencies for GitHub Actions in the future
  • Updated usage messages in examples/sample_usage/ of draw_cfg.py and print_ast.py to be accurate on all operating systems
  • Removed redundant line from tests/test_examples.py
  • Fixed minor typo in an error message in python_ta/cfg/visitor.py
  • Updated ExprWrapper to support set/list/tuple literals and in/not in operators
  • Updated snapshot.py and test_snapshot.py to align with MemoryViz 0.2.0 updates
  • Updated ExprWrapper to support string variables and ==, in/not in, indexing and slicing operators
  • Added protected _z3_vars attribute to ControlFlowGraph to store variables to be used in Z3 solver
  • Removed unused imports from python_ta/cfg/graph.py
  • Extended functionality of ExprWrapper class to include function definitions' arguments and name assignments
  • Added z3 to dependencies installed as part of the docs job in the GitHub Actions workflow
  • Added tests to maintain/increase coverage of visitor.py, graph.py, and ExprWrapper.py
  • Removed deprecated and redundant future argument from node.frame() call in invalid_name_checker.py
  • Updated pylint to v3.2.6 and astroid to v3.2.4 (no new checks were enabled by default)
  • Excluded node_modules/ folder from package autodiscovery
  • Updated graph.py to augment control flow graph edges with z3 constraints
  • Added support for the != operator and replaced dictionary indexing with .get in ExprWrapper.
  • Refactored Z3Visitor to use safe_infer() instead of inferred() and added handling of AstroidError.
  • Add negate attribute to CFGEdge

[2.7.0] 2023-12-14

14 Dec 20:29
Compare
Choose a tag to compare

Enhancements

  • Added new configuration option use-pyta-error-messages to let users choose whether PythonTA should overwrite pylint's error messages.
  • Both PlainReporter and ColorReporter emphasize specific code chunks by using overline characters under any part that is highlighted as ERROR.
  • Added snapshot function for deriving a list of dictionaries containing local variables from relevant functions and/or stack frames.
  • Added new configuration option allow-pylint-comments to let users choose whether PythonTA should allow comments beginning with pylint: or not.
  • AccumulationTable can now track variables initialized within the for loop. Prior, only variables initialized before the for loop could be tracked.
  • AccumulationTable now stores deep copies of objects rather than shallow copies, thus fixing issues that come up in case of mutation during loop.
  • AccumulationTable can now take in any accumulator expressions, for eg. x * 2, instead of just variables.
  • AccumulationTable now has an optional initialization argument output which allows the users to choose whether they want to write the Accumulation Table to a file.
  • Created a RecursionTable context manager for recursive tracing using a tabular output.
  • Support Python 3.12 (requiring upgrade to pylint and astroid 3.0)

Bug fixes

  • Fix bug in ending location setting for Attribute and DelAttr nodes when the same attribute was accessed twice on the same line.
  • Fix bug where the naming-convention-violation checker was checking variables defined in a module's main block. This was inconsistent with the forbidden-global-variables checker.
  • Fixed bug with invalid-range-index: do not attempt any inference of variables in range expressions. All range arguments involving variables will be ignored by this checker.

New checkers

Pylint checkers v3.0:

  • invalid-field-call
  • return-in-finally
  • kwarg-superseded-by-positional-arg
  • unnecessary-negation (renamed from unneeded-not)

For more information on these checkers, please see the Pylint release notes. Note that the above list only contains the Pylint checkers enabled by default in PythonTA.

Internal

  • Remove experimental type inference code.

[2.6.4] 2023-11-10

10 Nov 19:51
Compare
Choose a tag to compare

Bug fixes

  • Fixed bug with invalid-range-index when variables are used in range expressions.

[2.6.3] - 2023-10-09

09 Oct 16:19
Compare
Choose a tag to compare

Bug fixes

  • Ensure pycodestyle W503, line break before binary operator, is disabled (regression from 2.6.2).
  • Fix check_contracts typings so PyCharm static checking will work
  • Fix invalid-range-index bug where valid range calls were flagged as invalid

[2.6.2] - 2023-09-22

22 Sep 23:05
Compare
Choose a tag to compare

Bug fixes

  • Fix naming-convention-violation bug where _ was considered an invalid variable name.
  • Fix naming-convention-violation bug where top-level constants were being checked as regular variable names.

Enhancements

  • Created many custom renderers to make the code snippets for pep8-errors easier to understand.

[2.6.1] - 2023-08-13

13 Aug 15:05
Compare
Choose a tag to compare

Bug fixes

  • Make graphviz an optional dependency, and clarify the installation requirements for visualizing control flow graphs.
  • Fix handling of forward references in class type annotations when using check_contracts decorator.
  • Fix handling of | in type annotations (by updating to typeguard v4.1.0).

[2.6.0] - 2023-08-06

06 Aug 17:33
Compare
Choose a tag to compare

Updated 2023/08/13: This release required the graphviz Python library to be installed, but this library was not listed as a project dependency. graphviz has been moved to be an optional dependency in 2.6.1.

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.

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 check.

Pylint checkers v2.16:

  • pointless-exception-statement
  • shadowed-import
  • unbalanced-dict-unpacking
  • nested-min-max
  • invalid-slice-step

Pylint checkers v2.17:

  • bad-chained-comparison

For more information on these checkers, please see the Pylint release notes. Note that the above list only contains the Pylint checkers enabled by default in PythonTA.