Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-update pre-commit hooks #180

Merged
merged 9 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,18 @@ jobs:
os: ["ubuntu-latest"]
pandas: [""]
pyarrow: ["4.0.1", "nightly"]
python: ["3.8"]
python: ["3.10"]
include:
- numfocus_nightly: true
os: "ubuntu-latest"
pandas: ""
pyarrow: "nightly"
python: "3.10"
- numfocus_nightly: false
os: "ubuntu-latest"
pandas: "1.5.3"
pyarrow: "4.0.1"
python: "3.11"
- numfocus_nightly: false
os: "ubuntu-latest"
pandas: "1.5.3"
pyarrow: "13.0.0"
python: "3.11"
- numfocus_nightly: false
os: "ubuntu-latest"
pandas: ""
pyarrow: "5.0.0"
python: "3.9"
- numfocus_nightly: false
os: "ubuntu-latest"
pandas: ""
pyarrow: "6.0.1"
python: "3.9"
- numfocus_nightly: false
os: "ubuntu-latest"
pandas: ""
Expand Down Expand Up @@ -103,10 +88,10 @@ jobs:
pyarrow: "15.0.0"
python: "3.12"
- numfocus_nightly: false
os: "macos-latest"
os: "ubuntu-latest"
pandas: ""
pyarrow: "4.0.1"
python: "3.8"
pyarrow: "18.1.0"
python: "3.12"
continue-on-error: ${{ matrix.numfocus_nightly || matrix.pyarrow == 'nightly' }}

runs-on: ${{ matrix.os }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: 4.11.0-0
miniforge-variant: Miniforge3
miniforge-version: 24.9.2-0
use-mamba: true
environment-file: docs/environment-docs.yml
activate-environment: plateau-docs
python-version: 3.8
python-version: 3.12

- name: List conda
shell: bash -l {0}
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
# Run ruff first because autofix behaviour is enabled
- repo: https://github.com/Quantco/pre-commit-mirrors-ruff
rev: "0.7.2"
rev: "0.8.0"
hooks:
- id: ruff-conda
- id: ruff-format-conda
- repo: https://github.com/Quantco/pre-commit-mirrors-mypy
rev: "1.10.1"
rev: "1.13.0"
hooks:
- id: mypy-conda
files: plateau
Expand All @@ -17,16 +17,16 @@ repos:
- types-decorator
- types-simplejson
- hypothesis
- numpy=1.26
- numpy=2.1.3
- minimalkv=1.4.2
- repo: https://github.com/Quantco/pre-commit-mirrors-pyupgrade
rev: 3.15.2
rev: 3.19.0
hooks:
- id: pyupgrade-conda
args:
- --py38-plus
- --py310-plus
- repo: https://github.com/Quantco/pre-commit-mirrors-prettier
rev: 3.2.5
rev: 3.4.1
hooks:
- id: prettier-conda
files: "\\.md$"
Expand All @@ -35,7 +35,7 @@ repos:
hooks:
- id: docformatter-conda
- repo: https://github.com/Quantco/pre-commit-mirrors-pre-commit-hooks
rev: 4.6.0
rev: 5.0.0
hooks:
- id: trailing-whitespace-conda
- id: end-of-file-fixer-conda
2 changes: 1 addition & 1 deletion docs/environment-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies:
- decorator
- msgpack-python>=0.5.2
# Currently dask and numpy==1.16.0 clash
- numpy!=1.15.0,!=1.16.0
- numpy!=1.15.0,!=1.16.0,<2
- pandas>=0.23.0,!=1.0.0
- pyarrow>=4
- simplejson
Expand Down
4 changes: 3 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ channels:
- conda-forge
- nodefaults
dependencies:
- python>=3.10
- pip
- dask>=2022.5.1 # First version with dask.dataframe.from_map.
- decorator
- msgpack-python>=0.5.2
# Currently dask and numpy==1.16.0 clash
# TODO: add support for numpy>=1.23
- numpy!=1.15.0,!=1.16.0
- numpy!=1.15.0,!=1.16.0,<2
- pandas>=0.23.0,!=1.0.0
- pyarrow>=4
- simplejson
Expand Down
23 changes: 12 additions & 11 deletions plateau/core/common_metadata.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import difflib
import logging
import pprint
from collections.abc import Sequence
from copy import copy, deepcopy
from functools import reduce
from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, Union
from typing import Any

import pandas as pd
import pyarrow as pa
Expand Down Expand Up @@ -37,7 +38,7 @@ class SchemaWrapper:
"""Wrapper object for pyarrow.Schema to handle forwards and backwards
compatibility."""

def __init__(self, schema, origin: Union[str, Set[str]]):
def __init__(self, schema, origin: str | set[str]):
if isinstance(origin, str):
origin = {origin}
elif isinstance(origin, set):
Expand All @@ -49,7 +50,7 @@ def __init__(self, schema, origin: Union[str, Set[str]]):
self.__origin = origin
self._schema_compat()

def with_origin(self, origin: Union[str, Set[str]]) -> "SchemaWrapper":
def with_origin(self, origin: str | set[str]) -> "SchemaWrapper":
"""Create new SchemaWrapper with given origin.

Parameters
Expand Down Expand Up @@ -89,7 +90,7 @@ def internal(self):
return self.__schema

@property
def origin(self) -> Set[str]:
def origin(self) -> set[str]:
return copy(self.__origin)

def __repr__(self):
Expand Down Expand Up @@ -283,10 +284,10 @@ def make_meta(obj, origin, partition_keys=None):

def normalize_type(
t_pa: pa.DataType,
t_pd: Optional[str],
t_np: Optional[str],
metadata: Optional[Dict[str, Any]],
) -> Tuple[pa.DataType, Optional[str], Optional[str], Optional[Dict[str, Any]]]:
t_pd: str | None,
t_np: str | None,
metadata: dict[str, Any] | None,
) -> tuple[pa.DataType, str | None, str | None, dict[str, Any] | None]:
"""This will normalize types as followed:

- all signed integers (``int8``, ``int16``, ``int32``, ``int64``) will be converted to ``int64``
Expand Down Expand Up @@ -415,7 +416,7 @@ def _pandas_in_schemas(schemas):

def _determine_schemas_to_compare(
schemas: Sequence[SchemaWrapper], ignore_pandas: bool
) -> Tuple[Optional[SchemaWrapper], List[Tuple[SchemaWrapper, List[str]]]]:
) -> tuple[SchemaWrapper | None, list[tuple[SchemaWrapper, list[str]]]]:
"""Iterate over a list of `pyarrow.Schema` objects and prepares them for
comparison by picking a reference and determining all null columns.

Expand All @@ -436,7 +437,7 @@ def _determine_schemas_to_compare(
must be removed before comparing the schemas
"""
has_pandas = _pandas_in_schemas(schemas) and not ignore_pandas
schemas_to_evaluate: List[Tuple[SchemaWrapper, List[str]]] = []
schemas_to_evaluate: list[tuple[SchemaWrapper, list[str]]] = []
reference = None
null_cols_in_reference = set()

Expand Down Expand Up @@ -695,7 +696,7 @@ def validate_shared_columns(schemas, ignore_pandas=False):
ValueError
Incompatible columns were found.
"""
seen: Dict[str, Any] = {}
seen: dict[str, Any] = {}
has_pandas = _pandas_in_schemas(schemas) and not ignore_pandas

for schema in schemas:
Expand Down
Loading
Loading