Skip to content

Releases: pyta-uoft/pyta

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

[2.5.0] - 2023-04-27

27 Apr 16:06
Compare
Choose a tag to compare

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.

Other

  • Pin dependency versions

[2.4.2] - 2023-01-31

31 Jan 19:32
Compare
Choose a tag to compare

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.