diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 41cd452..837dad5 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -13,7 +13,7 @@ jobs: strategy: matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] - python-version: [ 3.6, 3.7, 3.8, 3.9 ] + python-version: [ "3.7", "3.8", "3.9", "3.10" ] steps: - uses: actions/checkout@v2 - name: Fetch complete history for all tags and branches diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 73805d8..cdf7db2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.1.0 hooks: - id: check-case-conflict - id: check-executables-have-shebangs @@ -12,20 +12,22 @@ repos: - id: end-of-file-fixer - id: mixed-line-ending - repo: https://github.com/psf/black - rev: 20.8b1 + rev: 22.1.0 hooks: - id: black - repo: https://github.com/timothycrosley/isort - rev: 5.7.0 + rev: 5.10.1 hooks: - id: isort args: [ --profile, black ] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.790 + rev: v0.931 hooks: - id: mypy files: ^binarytree/ + additional_dependencies: [ types-all ] + args: [ --strict ] - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.4 + rev: 4.0.1 hooks: - id: flake8 diff --git a/README.md b/README.md index 4f2f3f6..2476800 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![codecov](https://codecov.io/gh/joowani/binarytree/branch/main/graph/badge.svg?token=C2X2OMPL65)](https://codecov.io/gh/joowani/binarytree) [![PyPI version](https://badge.fury.io/py/binarytree.svg)](https://badge.fury.io/py/binarytree) [![GitHub license](https://img.shields.io/github/license/joowani/binarytree?color=brightgreen)](https://github.com/joowani/binarytree/blob/main/LICENSE) -![Python version](https://img.shields.io/badge/python-3.6%2B-blue) +![Python version](https://img.shields.io/badge/python-3.7%2B-blue) Are you studying binary trees for your next exam, assignment or technical interview? @@ -23,14 +23,14 @@ Binarytree can be used with [Graphviz](https://graphviz.org) and ## Requirements -Python 3.6+ +Python 3.7+ ## Installation Install via [pip](https://pip.pypa.io): ```shell -pip install binarytree +pip install binarytree --upgrade ``` For [conda](https://docs.conda.io) users: diff --git a/binarytree/__init__.py b/binarytree/__init__.py index 064d1bf..83c34ab 100644 --- a/binarytree/__init__.py +++ b/binarytree/__init__.py @@ -512,7 +512,7 @@ def svg(self, node_radius: int = 16) -> str: def scale_x(x: int, y: int) -> float: diff = tree_height - y - x = 2 ** (diff + 1) * x + 2 ** diff - 1 + x = 2 ** (diff + 1) * x + 2**diff - 1 return 1 + node_radius + scale * x / 2 def scale_y(y: int) -> float: @@ -562,7 +562,7 @@ def add_node(node_x: int, node_y: int, node_value: NodeValue) -> None: y += 1 return _SVG_XML_TEMPLATE.format( - width=scale * (2 ** tree_height), + width=scale * (2**tree_height), height=scale * (2 + tree_height), body="\n".join(xml), ) @@ -1833,7 +1833,7 @@ def _generate_random_leaf_count(height: int) -> int: :return: Random leaf count. :rtype: int """ - max_leaf_count = 2 ** height + max_leaf_count = 2**height half_leaf_count = max_leaf_count // 2 # A very naive way of mimicking normal distribution @@ -2016,7 +2016,7 @@ def _get_tree_properties(root: Node) -> NodeProperties: size=size, is_max_heap=is_complete and is_descending, is_min_heap=is_complete and is_ascending, - is_perfect=leaf_count == 2 ** max_leaf_depth, + is_perfect=leaf_count == 2**max_leaf_depth, is_strict=is_strict, is_complete=is_complete, leaf_count=leaf_count, @@ -2486,7 +2486,7 @@ def heap( if not is_perfect: # Randomly cut some of the leaf nodes away - random_cut = random.randint(2 ** height, len(values)) + random_cut = random.randint(2**height, len(values)) values = values[:random_cut] if is_max: diff --git a/docs/index.rst b/docs/index.rst index 83188b9..cf5849b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -5,7 +5,7 @@ Binarytree: Python Library for Studying Binary Trees :alt: GitHub License :target: https://github.com/joowani/binarytree/blob/main/LICENSE -.. image:: https://img.shields.io/badge/python-3.6%2B-blue +.. image:: https://img.shields.io/badge/python-3.7%2B-blue :alt: Python Versions Welcome to the documentation for **binarytree**. @@ -18,7 +18,7 @@ supported. Requirements ============ -Python 3.6+ +Python 3.7+ Installation ============ @@ -27,7 +27,7 @@ Install via pip_: .. code-block:: bash - pip install binarytree + pip install binarytree --upgrade For conda_ users: diff --git a/pyproject.toml b/pyproject.toml index 31dcdf5..41b4eb4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,3 +11,9 @@ testpaths = ["tests"] [tool.setuptools_scm] write_to = "binarytree/version.py" + +[tool.mypy] +warn_return_any = true +warn_unused_configs = true +ignore_missing_imports = true +strict = true diff --git a/setup.cfg b/setup.cfg index 65a7406..04b373c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,7 +3,3 @@ max-line-length = 88 extend-ignore = E203, E741, W503 exclude =.git .idea .*_cache dist htmlcov venv per-file-ignores = __init__.py:F401 conf.py:E402 - -[mypy] -ignore_missing_imports = True -strict = True diff --git a/setup.py b/setup.py index 9b0e83b..b9260a0 100644 --- a/setup.py +++ b/setup.py @@ -14,24 +14,24 @@ keywords=["tree", "heap", "bst", "education"], packages=find_packages(exclude=["tests"]), include_package_data=True, - python_requires=">=3.6", + python_requires=">=3.7", license="MIT", use_scm_version=True, setup_requires=["setuptools_scm"], install_requires=[ "graphviz", - "setuptools>=42", - "setuptools_scm[toml]>=3.4", + "setuptools>=60.8.2", + "setuptools_scm[toml]>=5.0.1", ], extras_require={ "dev": [ - "black", - "flake8>=3.8.4", - "isort>=5.0.0", - "mypy>=0.790", - "pre-commit>=2.9.3", - "pytest>=6.0.0", - "pytest-cov>=2.0.0", + "black>=22.1.0", + "flake8>=4.0.1", + "isort>=5.10.1", + "mypy>=0.931", + "pre-commit>=2.17.0", + "pytest>=6.2.1", + "pytest-cov>=2.10.1", "sphinx", "sphinx_rtd_theme", "types-setuptools",