Skip to content

Commit 4b7d453

Browse files
committed
remove dependency on six, drop support for python 3.7, update dev depdendencies
update pytest describe add flexible terminal string formatter start swapping in default formats start phasing out underline_cells wip wip demonstrate how custom formatting can be injected via pytest fixtures wip make sure format_string works with no formats add new custom formatter to readme bump to v0.10.0 New Chispa interface (#94) * add formats to dataframe comparer * add new chispa interface lock run tests for multiple python versions small fix add runs-on argument fix reset ci
1 parent bd822a4 commit 4b7d453

File tree

9 files changed

+437
-1282
lines changed

9 files changed

+437
-1282
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "setup-poetry-env"
2+
description: "Composite action to setup the Python and poetry environment."
3+
4+
inputs:
5+
python-version:
6+
required: false
7+
description: "The python version to use"
8+
default: "3.11"
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Set up python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: ${{ inputs.python-version }}
17+
18+
- name: Install Poetry
19+
env:
20+
# renovate: datasource=pypi depName=poetry
21+
POETRY_VERSION: "1.5.1"
22+
run: curl -sSL https://install.python-poetry.org | python - -y
23+
shell: bash
24+
25+
- name: Add Poetry to Path
26+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
27+
if: ${{ matrix.os != 'Windows' }}
28+
shell: bash
29+
30+
- name: Add Poetry to Path
31+
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
32+
if: ${{ matrix.os == 'Windows' }}
33+
shell: bash
34+
35+
- name: Configure Poetry virtual environment in project
36+
run: poetry config virtualenvs.in-project true
37+
shell: bash
38+
39+
- name: Load cached venv
40+
id: cached-poetry-dependencies
41+
uses: actions/cache@v3
42+
with:
43+
path: .venv
44+
key: venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('poetry.lock') }}
45+
46+
- name: Install dependencies
47+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
48+
run: poetry install --no-interaction
49+
shell: bash

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ chispa.egg-info/
55
tmp/
66
.idea/
77
.DS_Store
8+
.python_version
89

910
# Byte-compiled / optimized / DLL files
1011
__pycache__/

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,6 @@ TODO: Need to benchmark these methods vs. the spark-testing-base ones
475475

476476
## Vendored dependencies
477477

478-
These dependencies are vendored:
479-
480-
* [six](https://github.com/benjaminp/six)
481478
* [PrettyTable](https://github.com/jazzband/prettytable)
482479

483480
The dependencies are vendored to save you from dependency hell.

chispa/rows_comparer.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import chispa.six as six
1+
from itertools import zip_longest
22
from chispa.prettytable import PrettyTable
33
from chispa.bcolors import *
44
import chispa
@@ -11,8 +11,9 @@
1111
def assert_basic_rows_equality(rows1, rows2, underline_cells=False, formats=DefaultFormats()):
1212
if rows1 != rows2:
1313
t = PrettyTable(["df1", "df2"])
14-
zipped = list(six.moves.zip_longest(rows1, rows2))
14+
zipped = list(zip_longest(rows1, rows2))
1515
all_rows_equal = True
16+
1617
for r1, r2 in zipped:
1718
if r1 is None and r2 is not None:
1819
t.add_row([None, format_string(r2, formats.mismatched_rows)])
@@ -21,7 +22,7 @@ def assert_basic_rows_equality(rows1, rows2, underline_cells=False, formats=Defa
2122
t.add_row([format_string(r1, formats.mismatched_rows), None])
2223
all_rows_equal = False
2324
else:
24-
r_zipped = list(six.moves.zip_longest(r1.__fields__, r2.__fields__))
25+
r_zipped = list(zip_longest(r1.__fields__, r2.__fields__))
2526
r1_string = []
2627
r2_string = []
2728
for r1_field, r2_field in r_zipped:
@@ -43,7 +44,7 @@ def assert_basic_rows_equality(rows1, rows2, underline_cells=False, formats=Defa
4344
def assert_generic_rows_equality(rows1, rows2, row_equality_fun, row_equality_fun_args, underline_cells=False, formats=DefaultFormats()):
4445
df1_rows = rows1
4546
df2_rows = rows2
46-
zipped = list(six.moves.zip_longest(df1_rows, df2_rows))
47+
zipped = list(zip_longest(df1_rows, df2_rows))
4748
t = PrettyTable(["df1", "df2"])
4849
all_rows_equal = True
4950
for r1, r2 in zipped:
@@ -58,7 +59,7 @@ def assert_generic_rows_equality(rows1, rows2, row_equality_fun, row_equality_fu
5859
t.add_row([format_string(r1_string, formats.matched_rows), format_string(r2_string, formats.matched_rows)])
5960
# otherwise, rows aren't equal
6061
else:
61-
r_zipped = list(six.moves.zip_longest(r1.__fields__, r2.__fields__))
62+
r_zipped = list(zip_longest(r1.__fields__, r2.__fields__))
6263
r1_string = []
6364
r2_string = []
6465
for r1_field, r2_field in r_zipped:

chispa/schema_comparer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from chispa.prettytable import PrettyTable
22
from chispa.bcolors import *
3-
import chispa.six as six
3+
from itertools import zip_longest
44

55

66
class SchemasNotEqualError(Exception):
@@ -19,15 +19,15 @@ def assert_schema_equality_full(s1, s2, ignore_nullable=False, ignore_metadata=F
1919
def inner(s1, s2, ignore_nullable, ignore_metadata):
2020
if len(s1) != len(s2):
2121
return False
22-
zipped = list(six.moves.zip_longest(s1, s2))
22+
zipped = list(zip_longest(s1, s2))
2323
for sf1, sf2 in zipped:
2424
if not are_structfields_equal(sf1, sf2, ignore_nullable, ignore_metadata):
2525
return False
2626
return True
2727

2828
if not inner(s1, s2, ignore_nullable, ignore_metadata):
2929
t = PrettyTable(["schema1", "schema2"])
30-
zipped = list(six.moves.zip_longest(s1, s2))
30+
zipped = list(zip_longest(s1, s2))
3131
for sf1, sf2 in zipped:
3232
if are_structfields_equal(sf1, sf2, True):
3333
t.add_row([blue(sf1), blue(sf2)])
@@ -42,7 +42,7 @@ def inner(s1, s2, ignore_nullable, ignore_metadata):
4242
def assert_basic_schema_equality(s1, s2):
4343
if s1 != s2:
4444
t = PrettyTable(["schema1", "schema2"])
45-
zipped = list(six.moves.zip_longest(s1, s2))
45+
zipped = list(zip_longest(s1, s2))
4646
for sf1, sf2 in zipped:
4747
if sf1 == sf2:
4848
t.add_row([blue(sf1), blue(sf2)])
@@ -56,7 +56,7 @@ def assert_basic_schema_equality(s1, s2):
5656
def assert_schema_equality_ignore_nullable(s1, s2):
5757
if not are_schemas_equal_ignore_nullable(s1, s2):
5858
t = PrettyTable(["schema1", "schema2"])
59-
zipped = list(six.moves.zip_longest(s1, s2))
59+
zipped = list(zip_longest(s1, s2))
6060
for sf1, sf2 in zipped:
6161
if are_structfields_equal(sf1, sf2, True):
6262
t.add_row([blue(sf1), blue(sf2)])
@@ -69,7 +69,7 @@ def assert_schema_equality_ignore_nullable(s1, s2):
6969
def are_schemas_equal_ignore_nullable(s1, s2):
7070
if len(s1) != len(s2):
7171
return False
72-
zipped = list(six.moves.zip_longest(s1, s2))
72+
zipped = list(zip_longest(s1, s2))
7373
for sf1, sf2 in zipped:
7474
if not are_structfields_equal(sf1, sf2, True):
7575
return False

0 commit comments

Comments
 (0)