Skip to content

Commit

Permalink
Made fixes according to PR specifications
Browse files Browse the repository at this point in the history
  • Loading branch information
CulmoneY committed Sep 15, 2024
1 parent ab8fc96 commit 655c16c
Show file tree
Hide file tree
Showing 20 changed files with 31 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Removed `node` attribute for `Z3Parser`
- Renamed `reduce` method of `Z3Parser` to `parse`
- Renamed `test_expr_wrapper` to `test_z3_parser`
- Refactored codebase to use modern type annotations. Replaced `List` with `list`, `Dict` with `dict`, `Set` with `set`, and `Tuple` with `tuple`.

## [2.8.1] - 2024-08-19

Expand Down
1 change: 0 additions & 1 deletion docs/checkers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,6 @@ example below is considered to have _six_ nested blocks, not seven.
The code above can be fixed using a helper function:

```python

def drop_none(lst: list[Optional[int]]) -> list[int]:
"""Return a copy of `lst` with all `None` elements removed."""
new_lst = []
Expand Down
3 changes: 1 addition & 2 deletions examples/ending_locations/subscript.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations

y[0]
z [ 0 ]
a[:]
Expand All @@ -17,7 +18,5 @@
x = m[ : ]




def add(numbers: list[int]) -> list[int]:
return numbers + [1]
2 changes: 1 addition & 1 deletion python_ta/checkers/forbidden_io_function_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class IOFunctionChecker(BaseChecker):
"default": FORBIDDEN_BUILTIN,
"type": "csv",
"metavar": "<builtin function names>",
"help": "list of built-in function names that should not be used.",
"help": "List of built-in function names that should not be used.",
},
),
(
Expand Down
2 changes: 1 addition & 1 deletion python_ta/checkers/forbidden_python_syntax_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ForbiddenPythonSyntaxChecker(BaseChecker):
"default": (),
"type": "csv",
"metavar": "<disallowed-syntax>",
"help": "list of Python syntax that are not allowed to be used.",
"help": "List of Python syntax that are not allowed to be used.",
},
),
)
Expand Down
2 changes: 1 addition & 1 deletion python_ta/checkers/invalid_name_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Bad variable names.
BAD_NAMES = {"l", "I", "O"}

# set a limit in name length to keep certain variable names short.
# Set a limit in name length to keep certain variable names short.
VAR_NAME_LENGTHS = {
"module": 30,
"constant": 30,
Expand Down
2 changes: 1 addition & 1 deletion python_ta/checkers/pycodestyle_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PycodestyleChecker(BaseRawFileChecker):
"default": (),
"type": "csv",
"metavar": "<pycodestyle-ignore>",
"help": "list of Pycodestyle errors to ignore",
"help": "List of Pycodestyle errors to ignore",
},
),
)
Expand Down
2 changes: 1 addition & 1 deletion python_ta/contracts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

ENABLE_CONTRACT_CHECKING = True
"""
set to True to enable contract checking.
Set to True to enable contract checking.
"""

DEBUG_CONTRACTS = False
Expand Down
2 changes: 1 addition & 1 deletion python_ta/reporters/templates/jquery-3.7.1.slim.min.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions python_ta/reporters/templates/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $(".sidebar button").click(function () {
* https://carlanderson.xyz/how-to-animate-on-height-auto/
*/
function toggleElement(elem) {
const expanded = elem.classlist.contains("expanded")
const expanded = elem.classList.contains("expanded")
elem.style.height = ""
elem.style.transition = "none"

Expand All @@ -24,8 +24,8 @@ function toggleElement(elem) {
elem.style.height = startHeight
}

elem.classlist.toggle("hide-and-maintain-width")
elem.classlist.toggle("expanded")
elem.classList.toggle("hide-and-maintain-width")
elem.classList.toggle("expanded")

let height
if (expanded) {
Expand All @@ -45,8 +45,8 @@ function toggleElement(elem) {
})

// Clear the saved height values after the transition
elem.addEventlistener("transitionend", () => {
elem.addEventListener("transitionend", () => {
elem.style.height = ""
elem.removeEventlistener("transitionend", arguments.callee)
elem.removeEventListener("transitionend", arguments.callee)
})
}
2 changes: 1 addition & 1 deletion python_ta/transforms/setendings.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def end_setter_from_source(source_code, pred, only_consumables=False):
"""

def set_endings_from_source(node):
# tuple nodes have an end_col_offset that includes the end paren,
# Tuple nodes have an end_col_offset that includes the end paren,
# but their col_offset does not include the start paren.
# To address this, we override the tuple node's end_col_offset.
if not hasattr(node, "end_col_offset") or isinstance(node, nodes.Tuple):
Expand Down
4 changes: 3 additions & 1 deletion python_ta/transforms/z3_visitor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import astroid
from astroid import AstroidError, nodes
from astroid.transforms import TransformVisitor
Expand Down Expand Up @@ -30,7 +32,7 @@ def set_function_def_z3_constraints(self, node: nodes.FunctionDef):
for ann, arg in zip(annotations, arguments):
if ann is None:
continue
# TODO: what to do about subscripts ex. Set[int], list[Set[int]], ...
# TODO: what to do about subscripts ex. set[int], list[set[int]], ...
inferred = safe_infer(ann)
if isinstance(inferred, nodes.ClassDef):
types[arg.name] = inferred.name
Expand Down
14 changes: 7 additions & 7 deletions tests/test.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
# Default max amount of messages for reporter to display.
pyta-number-of-messages = 0

# (DEPRECATED: Use output-format option below.) set the [REPORTS] output-format option instead.
# (DEPRECATED: Use output-format option below.) Set the [REPORTS] output-format option instead.
# pyta-reporter = HTMLReporter

# set the location of the template for HTMLreporter.
# Set the location of the template for HTMLreporter.
pyta-template-file = template.html.jinja

#set whether you wish to opt-in to anonymous data collection of errors reported when you run PyTA.
#Set whether you wish to opt-in to anonymous data collection of errors reported when you run PyTA.
pyta-error-permission = no

#set whether you wish to opt-in to anonymous data collection of the files you run PyTA on.
#Set whether you wish to opt-in to anonymous data collection of the files you run PyTA on.
pyta-file-permission = no

# Server address for data submission participation.
Expand All @@ -28,20 +28,20 @@ output-format = python_ta.reporters.PlainReporter

[ELIF]

# set maximum allowed if nesting.
# Set maximum allowed if nesting.
max-nested-blocks = 3

[FORMAT]

# set the maximum line length. The maximum line length in pep8 is 80 characters.
# Set the maximum line length. The maximum line length in pep8 is 80 characters.
max-line-length = 80

# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines = ^\s*((# )?<?https?://\S+>?)|(>>>.*)$

[FORBIDDEN IMPORT]

# set the whitelist of modules that are allowed to be imported
# Set the whitelist of modules that are allowed to be imported
allowed-import-modules = dataclasses, doctest, unittest, hypothesis, pytest, python_ta, python_ta.contracts,
timeit, typing, __future__
extra-imports =
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cfg/test_cfg_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def reset_dir(request, monkeypatch):
@pytest.fixture
def create_cfg():
"""Create the CFG for each test that uses the code in a file fixture."""
# setup: store the paths of the files being used/created
# Setup: store the paths of the files being used/created
script_name = "file_fixtures/my_file.py"
dot_file_path = os.path.splitext(os.path.basename(script_name))[0]
svg_file_path = dot_file_path + ".svg"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_contracts/test_class_forward_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, item: Any) -> None:
self.next = None

def bad_method(self) -> None:
"""set self.next to an invalid value, violating the type annotation."""
"""Set self.next to an invalid value, violating the type annotation."""
self.next = 1


Expand Down
3 changes: 1 addition & 2 deletions tests/test_custom_checkers/test_type_annotation_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ def test_type_is_assigned_for_function(self):
"""Ensure that checker catches when type is assigned instead of annotated
in function parameters."""
src = """
from typing import list
from __future__ import annotations
def add_two_numbers(
x=int, # Error on this line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Make sure to register custom options tuple first in `python_ta/__init__.py`
# ===========================================================
# set whether the default error messages by pylint should be overwritten by python TA's custom messages
# Set whether the default error messages by pylint should be overwritten by python TA's custom messages
use-pyta-error-messages = no

[REPORTS]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Make sure to register custom options tuple first in `python_ta/__init__.py`
# ===========================================================
# set whether the default error messages by pylint should be overwritten by python TA's custom messages
# Set whether the default error messages by pylint should be overwritten by python TA's custom messages
use-pyta-error-messages = yes

[REPORTS]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Path to messages_config toml file
messages-config-path = tests/test_messages_config/test.messages_config.toml

# set whether the default error messages by pylint should be overwritten by python TA's custom messages
# Set whether the default error messages by pylint should be overwritten by python TA's custom messages
use-pyta-error-messages = no

[REPORTS]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Path to messages_config toml file
messages-config-path = tests/test_messages_config/test.messages_config.toml

# set whether the default error messages by pylint should be overwritten by python TA's custom messages
# Set whether the default error messages by pylint should be overwritten by python TA's custom messages
use-pyta-error-messages = yes

[REPORTS]
Expand Down

0 comments on commit 655c16c

Please sign in to comment.