diff --git a/sample_usage/__init__.py b/examples/__init__.py similarity index 100% rename from sample_usage/__init__.py rename to examples/__init__.py diff --git a/nodes/README.md b/examples/nodes/README.md similarity index 100% rename from nodes/README.md rename to examples/nodes/README.md diff --git a/nodes/ann_assign.py b/examples/nodes/ann_assign.py similarity index 100% rename from nodes/ann_assign.py rename to examples/nodes/ann_assign.py diff --git a/nodes/arguments.py b/examples/nodes/arguments.py similarity index 100% rename from nodes/arguments.py rename to examples/nodes/arguments.py diff --git a/nodes/assert.py b/examples/nodes/assert.py similarity index 100% rename from nodes/assert.py rename to examples/nodes/assert.py diff --git a/nodes/assign.py b/examples/nodes/assign.py similarity index 100% rename from nodes/assign.py rename to examples/nodes/assign.py diff --git a/nodes/assign_attr.py b/examples/nodes/assign_attr.py similarity index 100% rename from nodes/assign_attr.py rename to examples/nodes/assign_attr.py diff --git a/nodes/assign_name.py b/examples/nodes/assign_name.py similarity index 100% rename from nodes/assign_name.py rename to examples/nodes/assign_name.py diff --git a/nodes/async_for.py b/examples/nodes/async_for.py similarity index 100% rename from nodes/async_for.py rename to examples/nodes/async_for.py diff --git a/nodes/async_function_def.py b/examples/nodes/async_function_def.py similarity index 100% rename from nodes/async_function_def.py rename to examples/nodes/async_function_def.py diff --git a/nodes/async_with.py b/examples/nodes/async_with.py similarity index 100% rename from nodes/async_with.py rename to examples/nodes/async_with.py diff --git a/nodes/attribute.py b/examples/nodes/attribute.py similarity index 100% rename from nodes/attribute.py rename to examples/nodes/attribute.py diff --git a/nodes/aug_assign.py b/examples/nodes/aug_assign.py similarity index 100% rename from nodes/aug_assign.py rename to examples/nodes/aug_assign.py diff --git a/nodes/await.py b/examples/nodes/await.py similarity index 100% rename from nodes/await.py rename to examples/nodes/await.py diff --git a/nodes/bin_op.py b/examples/nodes/bin_op.py similarity index 100% rename from nodes/bin_op.py rename to examples/nodes/bin_op.py diff --git a/nodes/bool_op.py b/examples/nodes/bool_op.py similarity index 100% rename from nodes/bool_op.py rename to examples/nodes/bool_op.py diff --git a/nodes/break.py b/examples/nodes/break.py similarity index 100% rename from nodes/break.py rename to examples/nodes/break.py diff --git a/nodes/call.py b/examples/nodes/call.py similarity index 100% rename from nodes/call.py rename to examples/nodes/call.py diff --git a/nodes/class_def.py b/examples/nodes/class_def.py similarity index 100% rename from nodes/class_def.py rename to examples/nodes/class_def.py diff --git a/nodes/compare.py b/examples/nodes/compare.py similarity index 100% rename from nodes/compare.py rename to examples/nodes/compare.py diff --git a/nodes/comprehension.py b/examples/nodes/comprehension.py similarity index 100% rename from nodes/comprehension.py rename to examples/nodes/comprehension.py diff --git a/nodes/const.py b/examples/nodes/const.py similarity index 100% rename from nodes/const.py rename to examples/nodes/const.py diff --git a/nodes/continue.py b/examples/nodes/continue.py similarity index 100% rename from nodes/continue.py rename to examples/nodes/continue.py diff --git a/nodes/decorators.py b/examples/nodes/decorators.py similarity index 100% rename from nodes/decorators.py rename to examples/nodes/decorators.py diff --git a/nodes/del_attr.py b/examples/nodes/del_attr.py similarity index 100% rename from nodes/del_attr.py rename to examples/nodes/del_attr.py diff --git a/nodes/del_name.py b/examples/nodes/del_name.py similarity index 100% rename from nodes/del_name.py rename to examples/nodes/del_name.py diff --git a/nodes/delete.py b/examples/nodes/delete.py similarity index 100% rename from nodes/delete.py rename to examples/nodes/delete.py diff --git a/nodes/dict.py b/examples/nodes/dict.py similarity index 100% rename from nodes/dict.py rename to examples/nodes/dict.py diff --git a/nodes/dict_comp.py b/examples/nodes/dict_comp.py similarity index 100% rename from nodes/dict_comp.py rename to examples/nodes/dict_comp.py diff --git a/nodes/dict_unpack.py b/examples/nodes/dict_unpack.py similarity index 100% rename from nodes/dict_unpack.py rename to examples/nodes/dict_unpack.py diff --git a/nodes/ellipsis.py b/examples/nodes/ellipsis.py similarity index 100% rename from nodes/ellipsis.py rename to examples/nodes/ellipsis.py diff --git a/nodes/except_handler.py b/examples/nodes/except_handler.py similarity index 100% rename from nodes/except_handler.py rename to examples/nodes/except_handler.py diff --git a/nodes/expr.py b/examples/nodes/expr.py similarity index 100% rename from nodes/expr.py rename to examples/nodes/expr.py diff --git a/nodes/for.py b/examples/nodes/for.py similarity index 100% rename from nodes/for.py rename to examples/nodes/for.py diff --git a/nodes/formatted_value.py b/examples/nodes/formatted_value.py similarity index 100% rename from nodes/formatted_value.py rename to examples/nodes/formatted_value.py diff --git a/nodes/function_def.py b/examples/nodes/function_def.py similarity index 100% rename from nodes/function_def.py rename to examples/nodes/function_def.py diff --git a/nodes/generator_exp.py b/examples/nodes/generator_exp.py similarity index 100% rename from nodes/generator_exp.py rename to examples/nodes/generator_exp.py diff --git a/nodes/global.py b/examples/nodes/global.py similarity index 100% rename from nodes/global.py rename to examples/nodes/global.py diff --git a/nodes/if.py b/examples/nodes/if.py similarity index 100% rename from nodes/if.py rename to examples/nodes/if.py diff --git a/nodes/if_exp.py b/examples/nodes/if_exp.py similarity index 100% rename from nodes/if_exp.py rename to examples/nodes/if_exp.py diff --git a/nodes/import.py b/examples/nodes/import.py similarity index 100% rename from nodes/import.py rename to examples/nodes/import.py diff --git a/nodes/import_from.py b/examples/nodes/import_from.py similarity index 100% rename from nodes/import_from.py rename to examples/nodes/import_from.py diff --git a/nodes/joined_str.py b/examples/nodes/joined_str.py similarity index 100% rename from nodes/joined_str.py rename to examples/nodes/joined_str.py diff --git a/nodes/keyword.py b/examples/nodes/keyword.py similarity index 100% rename from nodes/keyword.py rename to examples/nodes/keyword.py diff --git a/nodes/lambda.py b/examples/nodes/lambda.py similarity index 100% rename from nodes/lambda.py rename to examples/nodes/lambda.py diff --git a/nodes/list.py b/examples/nodes/list.py similarity index 100% rename from nodes/list.py rename to examples/nodes/list.py diff --git a/nodes/list_comp.py b/examples/nodes/list_comp.py similarity index 100% rename from nodes/list_comp.py rename to examples/nodes/list_comp.py diff --git a/nodes/module.py b/examples/nodes/module.py similarity index 100% rename from nodes/module.py rename to examples/nodes/module.py diff --git a/nodes/name.py b/examples/nodes/name.py similarity index 100% rename from nodes/name.py rename to examples/nodes/name.py diff --git a/nodes/nonlocal.py b/examples/nodes/nonlocal.py similarity index 100% rename from nodes/nonlocal.py rename to examples/nodes/nonlocal.py diff --git a/nodes/pass.py b/examples/nodes/pass.py similarity index 100% rename from nodes/pass.py rename to examples/nodes/pass.py diff --git a/nodes/raise.py b/examples/nodes/raise.py similarity index 100% rename from nodes/raise.py rename to examples/nodes/raise.py diff --git a/nodes/return.py b/examples/nodes/return.py similarity index 100% rename from nodes/return.py rename to examples/nodes/return.py diff --git a/nodes/set.py b/examples/nodes/set.py similarity index 100% rename from nodes/set.py rename to examples/nodes/set.py diff --git a/nodes/set_comp.py b/examples/nodes/set_comp.py similarity index 100% rename from nodes/set_comp.py rename to examples/nodes/set_comp.py diff --git a/nodes/slice.py b/examples/nodes/slice.py similarity index 100% rename from nodes/slice.py rename to examples/nodes/slice.py diff --git a/nodes/starred.py b/examples/nodes/starred.py similarity index 100% rename from nodes/starred.py rename to examples/nodes/starred.py diff --git a/nodes/subscript.py b/examples/nodes/subscript.py similarity index 100% rename from nodes/subscript.py rename to examples/nodes/subscript.py diff --git a/nodes/try_except.py b/examples/nodes/try_except.py similarity index 100% rename from nodes/try_except.py rename to examples/nodes/try_except.py diff --git a/nodes/try_finally.py b/examples/nodes/try_finally.py similarity index 100% rename from nodes/try_finally.py rename to examples/nodes/try_finally.py diff --git a/nodes/tuple.py b/examples/nodes/tuple.py similarity index 100% rename from nodes/tuple.py rename to examples/nodes/tuple.py diff --git a/nodes/unary_op.py b/examples/nodes/unary_op.py similarity index 100% rename from nodes/unary_op.py rename to examples/nodes/unary_op.py diff --git a/nodes/while.py b/examples/nodes/while.py similarity index 100% rename from nodes/while.py rename to examples/nodes/while.py diff --git a/nodes/with.py b/examples/nodes/with.py similarity index 100% rename from nodes/with.py rename to examples/nodes/with.py diff --git a/nodes/yield.py b/examples/nodes/yield.py similarity index 100% rename from nodes/yield.py rename to examples/nodes/yield.py diff --git a/nodes/yield_from.py b/examples/nodes/yield_from.py similarity index 100% rename from nodes/yield_from.py rename to examples/nodes/yield_from.py diff --git a/sample_usage/README.md b/examples/sample_usage/README.md similarity index 94% rename from sample_usage/README.md rename to examples/sample_usage/README.md index af50b7831..c7ba8f078 100644 --- a/sample_usage/README.md +++ b/examples/sample_usage/README.md @@ -42,7 +42,7 @@ call `pyta_statistics` on the absolute path to the directory, as so: ```python >>> directory = "C:\\Users\\prof\\Documents\\course1\\projects" # for example ->>> from sample_usage.pyta_stats import pyta_statistics # while running python in the pyta directory +>>> from examples.sample_usage.pyta_stats import pyta_statistics # while running python in the pyta directory >>> pyta_statistics(directory) ``` @@ -54,7 +54,7 @@ aggregate (if it is a course directory). There are three Python files that contribute to the aggregation and calculation of statistics for Python TA: -- `sample_usage/pyta_stats.py` +- `examples/sample_usage/pyta_stats.py` - This module contains the `pyta_statistics` function that users run on the directory that they want to analyse. It aggregates statistics that are collected @@ -62,7 +62,7 @@ of statistics for Python TA: the actual statistics calculators contained in the `stats_analysis` module, and pretty-prints the results. -- `sample_usage/stats_analysis.py` +- `examples/sample_usage/stats_analysis.py` - This module performs all of the actual statistics calculation on data collected by `pyta_stats`. The main function, `summary`, takes in the data and calls diff --git a/sample_usage/TODO.md b/examples/sample_usage/TODO.md similarity index 87% rename from sample_usage/TODO.md rename to examples/sample_usage/TODO.md index c7f54b0e6..6ea2fe432 100644 --- a/sample_usage/TODO.md +++ b/examples/sample_usage/TODO.md @@ -7,7 +7,7 @@ AnnAssign Node: An AttributeError is raised because the transformer did not add 'end_lineno' attribute to the AnnAssign node. In the current example - found in `nodes/ann_assign.py`, only the last statement has the + found in `examples/nodes/ann_assign.py`, only the last statement has the 'end_lineno' attribute added to it. DictUnpack Node: diff --git a/examples/sample_usage/__init__.py b/examples/sample_usage/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/sample_usage/draw_cfg.py b/examples/sample_usage/draw_cfg.py similarity index 78% rename from sample_usage/draw_cfg.py rename to examples/sample_usage/draw_cfg.py index b572c2321..fe631af7e 100644 --- a/sample_usage/draw_cfg.py +++ b/examples/sample_usage/draw_cfg.py @@ -1,6 +1,6 @@ import python_ta.cfg -USAGE = "USAGE: python -m sample_usage.draw_cfg " +USAGE = "USAGE: python -m examples.sample_usage.draw_cfg " def main(filepath: str) -> None: diff --git a/sample_usage/draw_tnodes.py b/examples/sample_usage/draw_tnodes.py similarity index 97% rename from sample_usage/draw_tnodes.py rename to examples/sample_usage/draw_tnodes.py index 7e533b53a..d0fe3c4dd 100644 --- a/sample_usage/draw_tnodes.py +++ b/examples/sample_usage/draw_tnodes.py @@ -9,7 +9,7 @@ from python_ta.typecheck.base import TypeFail, _TNode from tests.custom_hypothesis_support import _parse_text -USAGE = "Usage: python -m sample_usage.draw_tnodes " +USAGE = "Usage: python -m examples.sample_usage.draw_tnodes " def _type_str(type): diff --git a/sample_usage/print_ast.py b/examples/sample_usage/print_ast.py similarity index 95% rename from sample_usage/print_ast.py rename to examples/sample_usage/print_ast.py index 901741b88..c487db02e 100644 --- a/sample_usage/print_ast.py +++ b/examples/sample_usage/print_ast.py @@ -6,7 +6,7 @@ import astroid from colorama import Back, Fore -USAGE = "Usage: python -m sample_usage.print_ast " +USAGE = "Usage: python -m examples.sample_usage.print_ast " FILL = " " # Unicode Box Drawing Characters. CHAR_PIPE = "┃" diff --git a/sample_usage/print_nodes.py b/examples/sample_usage/print_nodes.py similarity index 96% rename from sample_usage/print_nodes.py rename to examples/sample_usage/print_nodes.py index de8c4ab14..93c1e4cdf 100644 --- a/sample_usage/print_nodes.py +++ b/examples/sample_usage/print_nodes.py @@ -76,7 +76,7 @@ def print_node(filename, node_class): if __name__ == "__main__": for node_class in astroid.nodes.ALL_NODE_CLASSES: print("=== {} ===".format(node_class.__name__)) - file_location = "nodes/" + inflection.underscore(node_class.__name__) + ".py" + file_location = "examples/nodes/" + inflection.underscore(node_class.__name__) + ".py" try: print_node(file_location, node_class) except FileNotFoundError: diff --git a/sample_usage/print_table.py b/examples/sample_usage/print_table.py similarity index 100% rename from sample_usage/print_table.py rename to examples/sample_usage/print_table.py diff --git a/sample_usage/pyta_stats.py b/examples/sample_usage/pyta_stats.py similarity index 99% rename from sample_usage/pyta_stats.py rename to examples/sample_usage/pyta_stats.py index 7bbf202d7..71a50c447 100644 --- a/sample_usage/pyta_stats.py +++ b/examples/sample_usage/pyta_stats.py @@ -3,7 +3,7 @@ import python_ta from python_ta.reporters.stat_reporter import StatReporter -from sample_usage.stats_analysis import summary +from examples.sample_usage.stats_analysis import summary def pyta_statistics(directory, config=""): diff --git a/sample_usage/stats_analysis.py b/examples/sample_usage/stats_analysis.py similarity index 100% rename from sample_usage/stats_analysis.py rename to examples/sample_usage/stats_analysis.py diff --git a/sample_usage/typecheck/fail/1_one_var_two_types.py b/examples/sample_usage/typecheck/fail/1_one_var_two_types.py similarity index 100% rename from sample_usage/typecheck/fail/1_one_var_two_types.py rename to examples/sample_usage/typecheck/fail/1_one_var_two_types.py diff --git a/sample_usage/typecheck/fail/2_add_str_int.py b/examples/sample_usage/typecheck/fail/2_add_str_int.py similarity index 100% rename from sample_usage/typecheck/fail/2_add_str_int.py rename to examples/sample_usage/typecheck/fail/2_add_str_int.py diff --git a/sample_usage/typecheck/fail/3_comp_str_bool.py b/examples/sample_usage/typecheck/fail/3_comp_str_bool.py similarity index 100% rename from sample_usage/typecheck/fail/3_comp_str_bool.py rename to examples/sample_usage/typecheck/fail/3_comp_str_bool.py diff --git a/sample_usage/typecheck/fail/4_comp_int_bool.py b/examples/sample_usage/typecheck/fail/4_comp_int_bool.py similarity index 100% rename from sample_usage/typecheck/fail/4_comp_int_bool.py rename to examples/sample_usage/typecheck/fail/4_comp_int_bool.py diff --git a/sample_usage/typecheck/fail/5_nested_calls.py b/examples/sample_usage/typecheck/fail/5_nested_calls.py similarity index 100% rename from sample_usage/typecheck/fail/5_nested_calls.py rename to examples/sample_usage/typecheck/fail/5_nested_calls.py diff --git a/sample_usage/typecheck/fail/6_call_in_add.py b/examples/sample_usage/typecheck/fail/6_call_in_add.py similarity index 100% rename from sample_usage/typecheck/fail/6_call_in_add.py rename to examples/sample_usage/typecheck/fail/6_call_in_add.py diff --git a/sample_usage/typecheck/pass/1_two_vars_one_type.py b/examples/sample_usage/typecheck/pass/1_two_vars_one_type.py similarity index 100% rename from sample_usage/typecheck/pass/1_two_vars_one_type.py rename to examples/sample_usage/typecheck/pass/1_two_vars_one_type.py diff --git a/sample_usage/typecheck/pass/2_int_condition.py b/examples/sample_usage/typecheck/pass/2_int_condition.py similarity index 100% rename from sample_usage/typecheck/pass/2_int_condition.py rename to examples/sample_usage/typecheck/pass/2_int_condition.py diff --git a/pyproject.toml b/pyproject.toml index c28a3ceed..ead16929a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,67 @@ +[project] +name = "python-ta" +description = "Code checking tool for teaching Python" +authors = [ + {name = "David Liu", email = "david@cs.toronto.edu"}, +] +license = {text = "MIT"} +readme = "README.md" +dependencies = [ + "astroid ~= 2.15.4", + "click >= 8.0.1, < 9", + "colorama ~= 0.4.6", + "jinja2 ~= 3.1.2", + "pycodestyle ~= 2.10.0", + "pygments ~= 2.14.0", + "pylint ~= 2.17.4", + "requests ~= 2.28.0", + "six", + "tabulate ~= 0.9.0", + "toml ~= 0.10.2", + "typeguard >= 2.13.3, < 3", + "wrapt >= 1.15.0, < 2", +] +dynamic = ["version"] +requires-python = ">=3.8" + +[project.optional-dependencies] +dev = [ + "graphviz", + "hypothesis", + "inflection", + "myst-parser", + "pre-commit", + "pytest", + "pytest-snapshot", + "pytest-cov ~= 4.0.0", + "sphinx", + "sphinx-rtd-theme", +] +z3 = [ + "z3-solver", +] + +[project.scripts] +python_ta = "python_ta.__main__:main" + +[project.urls] +Homepage = "https://github.com/pyta-uoft/pyta" +Documentation = "https://www.cs.toronto.edu/~david/pyta/" +Repository = "https://github.com/pyta-uoft/pyta.git" +Changelog = "https://github.com/pyta-uoft/pyta/blob/master/CHANGELOG.md" + + [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" +[tool.setuptools] +include-package-data = true +zip-safe = false + +[tool.setuptools.dynamic] +version = {attr = "python_ta.__version__"} +#readme = {file = "README.md", content-type = "text/markdown"} [tool.black] extend-exclude = ''' diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d14585154..000000000 --- a/setup.cfg +++ /dev/null @@ -1,49 +0,0 @@ -[metadata] -name = python-ta -version = attr: python_ta.__version__ -description = Code checking tool for teaching Python -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/pyta-uoft/pyta -author = David Liu -author_email = david@cs.toronto.edu -license = MIT - -[options] -install_requires = - astroid ~= 2.15.4 - pycodestyle ~= 2.10.0 - pylint ~= 2.17.4 - tabulate ~= 0.9.0 - colorama ~= 0.4.6 - six - jinja2 ~= 3.1.2 - pygments ~= 2.14.0 - wrapt >= 1.15.0, < 2 - typeguard >= 2.13.3, < 3 - requests ~= 2.28.0 - click >= 8.0.1, < 9 - toml ~= 0.10.2 -packages = find: -python_requires = ~=3.8 -zip_safe = False -include_package_data = True - -[options.extras_require] -dev = - graphviz - hypothesis - inflection - myst-parser - pre-commit - pytest - pytest-snapshot - pytest-cov ~= 4.0.0 - sphinx - sphinx-rtd-theme -z3 = - z3-solver - -[options.entry_points] -console_scripts = - python_ta = python_ta.__main__:main diff --git a/tests/test_check.py b/tests/test_check.py index 739443bec..3dbc33b78 100644 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -27,7 +27,7 @@ def test_check_on_dir(): def test_check_on_file(): """Test files""" - _inputs = [["nodes/name.py"], ["nodes/dict.py", "nodes/const.py"]] + _inputs = [["examples/nodes/name.py"], ["examples/nodes/dict.py", "examples/nodes/const.py"]] for item in _inputs: python_ta.check_all( item, @@ -46,8 +46,8 @@ def test_check_on_bad_input(): _inputs = [ [222], 222, - ["nodes/dict.py nodes/const.py"], - [222, "examples/inline_config_comment.py", "nodes/dict.py"], + ["examples/nodes/dict.py examples/nodes/const.py"], + [222, "examples/inline_config_comment.py", "examples/nodes/dict.py"], ["file_does_not_exist"], ] for item in _inputs: @@ -63,7 +63,7 @@ def test_check_on_bad_input(): def test_check_with_config(): """Test inputs along with a config arg.""" - _inputs = [["nodes/const.py"], ["nodes"]] + _inputs = [["examples/nodes/const.py"], ["examples/nodes"]] CONFIG = { # [ELIF] "max-nested-blocks": 4, @@ -172,7 +172,7 @@ def test_check_with_config(): def test_check_saves_file() -> None: """Test whether or not specifiying an output properly saves a file""" - _inputs = [["nodes/name.py"]] + _inputs = [["examples/nodes/name.py"]] for item in _inputs: # Note that the reporter output will be created in the main directory python_ta.check_all(item, output="pyta_output.html") @@ -195,7 +195,7 @@ def test_check_no_reporter_output() -> None: webbrowser.open = Mock(return_value=None) HTTPServer.handle_request = Mock(return_value=None) - _inputs = [["nodes/name.py"]] + _inputs = [["examples/nodes/name.py"]] for item in _inputs: # Note that the reporter output *would have been* created in the main directory python_ta.check_all(item) @@ -234,7 +234,7 @@ def test_check_errors_nonzero() -> None: "python_ta", "--config", "tests/test.pylintrc", - "nodes/name.py", + "examples/nodes/name.py", ] ) @@ -253,7 +253,7 @@ def test_check_exit_zero() -> None: "--exit-zero", "--config", "tests/test.pylintrc", - "nodes/name.py", + "examples/nodes/name.py", ] ) diff --git a/tests/test_type_constraints/test_tnode_structure.py b/tests/test_type_constraints/test_tnode_structure.py index 5b689266d..ee2b99459 100644 --- a/tests/test_type_constraints/test_tnode_structure.py +++ b/tests/test_type_constraints/test_tnode_structure.py @@ -4,8 +4,8 @@ import pytest from astroid import nodes +from examples.sample_usage.draw_tnodes import gen_graph_from_nodes from python_ta.typecheck.base import TypeConstraints, TypeFail, _TNode -from sample_usage.draw_tnodes import gen_graph_from_nodes from .. import custom_hypothesis_support as cs