Skip to content

Commit bfcb8d8

Browse files
authored
Merge branch 'master' into upgrade_hooks
2 parents 18a7b9b + becb012 commit bfcb8d8

File tree

6 files changed

+119
-7
lines changed

6 files changed

+119
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Release 1.6
44

55
- Upgraded pre-commit hooks (pre-commit-hooks to `v5.0.0` and ruff-pre-commit to `v0.6.0`)
6+
- Added [run-test.sh](run-tests.sh) script that runs all checks on code
67
- Added support for Python 3.12 and 3.13 by upgrading Pylint and disabling/fixing Pylint errors
78
- Corrected and improved language consistency in [readme](README.md) and `CHANGELOG.md`
89

DEVELOPER.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
For every release, the following process is used.
55

66
### Before Release
7-
1. From the project directory, run `./run-tests.sh` to insure unit tests pass (on python 2 and 3),
7+
1. From the project directory, run [./run-tests.sh](run-tests.sh) to insure unit tests pass (on python 2 and 3),
88
and that pylint succeeds
99
2. Push commit which is the candidate release to Github master
1010
3. Wait for tests to pass on [TravisCI](https://travis-ci.org/EntilZha/PyFunctional)

functional/pipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
from collections.abc import Iterable
4040

4141
# pylint: disable=deprecated-class
42-
from typing import Callable, Any, Iterator, NoReturn, Hashable
42+
from typing import Callable, Any, NoReturn
43+
from collections.abc import Iterator, Hashable
4344
from _typeshed import SupportsRichComparison
4445
from _typeshed import SupportsRichComparisonT
4546
from typing_extensions import TypeGuard

functional/streams.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import builtins
77

88
from itertools import chain
9-
from typing import Any, Iterable, Iterator, SupportsIndex
10-
from typing import TypeVar, overload
9+
from typing import Any, SupportsIndex, TypeVar, overload
10+
from collections.abc import Iterable, Iterator
1111
import typing
1212

1313
from functional.execution import ExecutionEngine, ParallelExecutionEngine

pyproject.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ pandas = { version = ">=1.0.3", optional = true }
3737
[tool.poetry.extras]
3838
all = ["pandas"]
3939

40-
[tool.poetry.dev-dependencies]
40+
[tool.poetry.group.dev.dependencies]
4141
black = "^23.1"
4242
pytest = "^7.3.1"
4343
pylint = "^3.3.3"
4444
pytest-cov = "^4.0.0"
4545
coverage = "^7.2.5"
46-
47-
[tool.poetry.group.dev.dependencies]
4846
mypy = "^1.1.1"
4947
types-tabulate = "^0.9.0.3"
5048
pandas-stubs = "^2.0.3.230814"

run-tests.sh

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
2+
# campare_versions(v1, v2)
3+
# 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.
4+
compare_versions() {
5+
local v1=(${1//./ })
6+
local v2=(${2//./ })
7+
8+
for i in {0..2}; do
9+
if [[ ${v1[i]} -lt ${v2[i]} ]]; then
10+
# Version $1 is less than $2
11+
echo -1
12+
return
13+
elif [[ ${v1[i]} -gt ${v2[i]} ]]; then
14+
# Version $1 is greater than $2"
15+
echo 1
16+
return
17+
fi
18+
done
19+
# "Version $1 is equal to $2"
20+
echo 0
21+
}
22+
23+
# get_version_in_pipx(package_name)
24+
# Gets the standard semantic version of a package installed in Pipx if installed.
25+
get_version_in_pipx() {
26+
local package_name=$1
27+
local version
28+
version=$(pipx list | grep -oP "$package_name"\\s+\\K\[0-9\]+\.\[0-9\]+\.\[0-9\]+)
29+
echo "$version"
30+
}
31+
32+
# capitalise(word)
33+
# Capitalizes a word.
34+
capitalize() {
35+
local word=$1
36+
echo "$(tr '[:lower:]' '[:upper:]' <<< "${word:0:1}")${word:1}"
37+
}
38+
39+
# print_version(name, version, capitalize, width)
40+
# Prints the version of the software with option to capitalize name and change left-aligned padding.
41+
print_version() {
42+
local name=$1
43+
local version=$2
44+
local capitalize=${3:-true}
45+
local width=${4:-19}
46+
name=$([[ $capitalize == 'true' ]] && capitalize "$name" || echo "$name")
47+
printf "%-${width}s %s\n" "$name version:" "$version"
48+
}
49+
50+
# install_package(package_name)
51+
# Installs specified package with Pipx or displays the its version if it's already installed.
52+
install_package() {
53+
local package_name=$1
54+
local capitalize=${2:-true}
55+
56+
local version
57+
version=$(get_version_in_pipx "$package_name")
58+
if [[ -n $version ]]; then
59+
print_version "$package_name" "$version" "$capitalize"
60+
else
61+
pipx install "$package_name"
62+
pipx ensurepath
63+
fi
64+
}
65+
66+
main() {
67+
local python_version
68+
python_version=$(python --version | awk '{print $2}')
69+
print_version "Python" "$python_version"
70+
71+
local pipx_version
72+
pipx_version=$(pipx --version)
73+
if [[ -z "$pipx_version" ]]; then
74+
echo "Please install Pipx before running this script."
75+
exit 1
76+
else
77+
print_version "Pipx" "$pipx_version"
78+
fi
79+
80+
install_package "poetry"
81+
82+
install_package "pre-commit" false
83+
84+
echo
85+
86+
if ! poetry install; then
87+
poetry lock
88+
poetry install
89+
fi
90+
91+
echo
92+
93+
poetry run pylint functional
94+
95+
echo
96+
97+
poetry run ruff check functional
98+
99+
echo
100+
101+
poetry run black --diff --color --check functional
102+
103+
echo
104+
105+
poetry run mypy functional
106+
107+
echo
108+
109+
poetry run pytest
110+
}
111+
112+
main "$@"

0 commit comments

Comments
 (0)