Skip to content
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: 22 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
PYTHON_VERSION: "3.10" # Because of pandas types
jobs:
clippy:
name: Clippy
Expand All @@ -33,11 +34,31 @@ jobs:
uses: Swatinem/[email protected]
- name: Run cargo fmt
run: cargo fmt --all -- --check
python-linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install Just
uses: taiki-e/install-action@just
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
- name: Install dependencies
run: |
pip install -U pip
pip install -r requirements-dev.txt
pip install -e .[all]
maturin build --out dist
pip install --no-index --find-links=dist/ prelude-parser
- name: mypy check
run: just mypy
test:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ pip install prelude-parser

Optionally the `pandas` extra can be installed to parse to a Pandas `DataFrame`

Note: Pandas only supports Python 3.9+ so this is not available in Python 3.8.

```sh
pip install prelude-parser[pandas]
```
Expand Down
4 changes: 0 additions & 4 deletions prelude_parser/pandas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import sys
from pathlib import Path

from prelude_parser._prelude_parser import _parse_flat_file_to_pandas_dict
Expand All @@ -13,9 +12,6 @@ class UnsupportedPythonVersionError(Exception):
try:
import pandas as pd
except ImportError as e: # pragma: no cover
if sys.version_info < (3, 9): # pargma: no cover
raise UnsupportedPythonVersionError("Pandas only supports Python 3.9+") from e

raise ImportError(
"prelude-parser must be installed with the pandas or all extra to use pandas"
) from e
Expand Down
6 changes: 4 additions & 2 deletions prelude_parser/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# UP035 and UP006 ignored because Python 3.9 doesn't support the upgrade

from datetime import date, datetime
from typing import Dict, List, Union
from typing import Dict, List, Union # noqa: UP035

FieldInfo = Union[str, int, float, date, datetime, None]
FlatFormInfo = List[Dict[str, FieldInfo]]
FlatFormInfo = List[Dict[str, FieldInfo]] # noqa: UP006
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ build-backend = "maturin"

[project]
name = "prelude-parser"
requires-python = ">=3.8"
requires-python = ">=3.9"
description = "Parses XML files exported from Prelude EDC into formats usable by Python."
authors = [{name = "Paul Sanders", email = "[email protected]"}]
keywords = ["parser", "prelude-edc", "xml", "pandas", "polars"]
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -29,9 +28,9 @@ documentation = "https://github.com/pbs-data-solutions/prelude-parser"
dependencies = ["camel-converter>=3.0.0"]

[project.optional-dependencies]
pandas = ['pandas>=2.1.0; python_version>"3.8"']
pandas = ["pandas>=2.1.0"]
polars = ["polars>=0.17.14"]
all = ['pandas>=2.1.0; python_version>"3.8"', "polars>=0.17.14"]
all = ["pandas>=2.1.0", "polars>=0.17.14"]

[tool.maturin]
module-name = "prelude_parser._prelude_parser"
Expand All @@ -52,7 +51,7 @@ disallow_untyped_defs = false

[tool.ruff]
line-length = 100
target-version = "py38"
target-version = "py39"
fix = true

[tool.ruff.lint]
Expand Down
11 changes: 2 additions & 9 deletions tests/test_pandas.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import sys
import pandas as pd

import pytest
from prelude_parser.pandas import to_dataframe

if sys.version_info >= (3, 9):
import pandas as pd

from prelude_parser.pandas import to_dataframe


@pytest.mark.skipif(sys.version_info < (3, 9), reason="Pandas only supports 3.9+")
def test_pandas_to_dataframe(test_file_1):
result = to_dataframe(test_file_1)
data = {
Expand All @@ -32,7 +26,6 @@ def test_pandas_to_dataframe(test_file_1):
assert expected.equals(result)


@pytest.mark.skipif(sys.version_info < (3, 9), reason="Pandas only supports 3.9+")
def test_pandas_to_dataframe_short_names(test_file_4):
result = to_dataframe(test_file_4, short_names=True)
data = {
Expand Down