diff --git a/CHANGELOG.md b/CHANGELOG.md index 897b446..592ff30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Release 1.6 +- Added [run-test.sh](run-tests.sh) script that runs all checks on code - Added support for Python 3.12 and 3.13 by upgrading Pylint and disabling/fixing Pylint errors - Corrected and improved language consistency in [readme](README.md) and `CHANGELOG.md` diff --git a/DEVELOPER.md b/DEVELOPER.md index d3ca0c1..81ce442 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -4,7 +4,7 @@ For every release, the following process is used. ### Before Release -1. From the project directory, run `./run-tests.sh` to insure unit tests pass (on python 2 and 3), +1. From the project directory, run [./run-tests.sh](run-tests.sh) to insure unit tests pass (on python 2 and 3), and that pylint succeeds 2. Push commit which is the candidate release to Github master 3. Wait for tests to pass on [TravisCI](https://travis-ci.org/EntilZha/PyFunctional) diff --git a/functional/pipeline.py b/functional/pipeline.py index 805577a..d923994 100644 --- a/functional/pipeline.py +++ b/functional/pipeline.py @@ -39,7 +39,8 @@ from collections.abc import Iterable # pylint: disable=deprecated-class - from typing import Callable, Any, Iterator, NoReturn, Hashable + from typing import Callable, Any, NoReturn + from collections.abc import Iterator, Hashable from _typeshed import SupportsRichComparison from _typeshed import SupportsRichComparisonT from typing_extensions import TypeGuard diff --git a/functional/streams.py b/functional/streams.py index 1f8a605..86d769c 100644 --- a/functional/streams.py +++ b/functional/streams.py @@ -6,8 +6,8 @@ import builtins from itertools import chain -from typing import Any, Iterable, Iterator, SupportsIndex -from typing import TypeVar, overload +from typing import Any, SupportsIndex, TypeVar, overload +from collections.abc import Iterable, Iterator import typing from functional.execution import ExecutionEngine, ParallelExecutionEngine diff --git a/pyproject.toml b/pyproject.toml index 6747909..d79f56f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,14 +37,12 @@ pandas = { version = ">=1.0.3", optional = true } [tool.poetry.extras] all = ["pandas"] -[tool.poetry.dev-dependencies] +[tool.poetry.group.dev.dependencies] black = "^23.1" pytest = "^7.3.1" pylint = "^3.3.3" pytest-cov = "^4.0.0" coverage = "^7.2.5" - -[tool.poetry.group.dev.dependencies] mypy = "^1.1.1" types-tabulate = "^0.9.0.3" pandas-stubs = "^2.0.3.230814" diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 0000000..2d709b0 --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,112 @@ + +# campare_versions(v1, v2) +# Compares two 3-part sematic versions, returning -1 if v1 is less than v2, 1 if v1 is greater than v2 or 0 if v1 and v2 are equal. +compare_versions() { + local v1=(${1//./ }) + local v2=(${2//./ }) + + for i in {0..2}; do + if [[ ${v1[i]} -lt ${v2[i]} ]]; then + # Version $1 is less than $2 + echo -1 + return + elif [[ ${v1[i]} -gt ${v2[i]} ]]; then + # Version $1 is greater than $2" + echo 1 + return + fi + done + # "Version $1 is equal to $2" + echo 0 +} + +# get_version_in_pipx(package_name) +# Gets the standard semantic version of a package installed in Pipx if installed. +get_version_in_pipx() { + local package_name=$1 + local version + version=$(pipx list | grep -oP "$package_name"\\s+\\K\[0-9\]+\.\[0-9\]+\.\[0-9\]+) + echo "$version" +} + +# capitalise(word) +# Capitalizes a word. +capitalize() { + local word=$1 + echo "$(tr '[:lower:]' '[:upper:]' <<< "${word:0:1}")${word:1}" +} + +# print_version(name, version, capitalize, width) +# Prints the version of the software with option to capitalize name and change left-aligned padding. +print_version() { + local name=$1 + local version=$2 + local capitalize=${3:-true} + local width=${4:-19} + name=$([[ $capitalize == 'true' ]] && capitalize "$name" || echo "$name") + printf "%-${width}s %s\n" "$name version:" "$version" +} + +# install_package(package_name) +# Installs specified package with Pipx or displays the its version if it's already installed. +install_package() { + local package_name=$1 + local capitalize=${2:-true} + + local version + version=$(get_version_in_pipx "$package_name") + if [[ -n $version ]]; then + print_version "$package_name" "$version" "$capitalize" + else + pipx install "$package_name" + pipx ensurepath + fi +} + +main() { + local python_version + python_version=$(python --version | awk '{print $2}') + print_version "Python" "$python_version" + + local pipx_version + pipx_version=$(pipx --version) + if [[ -z "$pipx_version" ]]; then + echo "Please install Pipx before running this script." + exit 1 + else + print_version "Pipx" "$pipx_version" + fi + + install_package "poetry" + + install_package "pre-commit" false + + echo + + if ! poetry install; then + poetry lock + poetry install + fi + + echo + + poetry run pylint functional + + echo + + poetry run ruff check functional + + echo + + poetry run black --diff --color --check functional + + echo + + poetry run mypy functional + + echo + + poetry run pytest +} + +main "$@" \ No newline at end of file