Skip to content

Commit

Permalink
Fix-dtype-conversion-bug
Browse files Browse the repository at this point in the history
* properly catch and handle errors in dtype conversion

* simplified and removed repetition in test sessions

* version bump
  • Loading branch information
Nacho Maiz authored Feb 9, 2024
1 parent 841ee35 commit 326c4ee
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 62 deletions.
2 changes: 1 addition & 1 deletion bavapi/parsing/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,5 @@ def convert_numeric(series: pd.Series) -> pd.Series:
return series
try:
return series.astype(int)
except ValueError:
except (ValueError, TypeError):
return series.astype(float, errors="ignore")
6 changes: 6 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## `1.0`

### `1.0.3` (2024-02-09)

#### Fix

- :bug: Fix bug in custom dtype conversion within the response parsing logic.

### `1.0.2` (2024-02-08)

#### Fix
Expand Down
85 changes: 25 additions & 60 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=import-outside-toplevel, invalid-name
# pylint: disable=import-outside-toplevel

"""Package tooling session definitions for `nox`"""

Expand All @@ -9,117 +9,82 @@

import nox

python_versions = ("3.8", "3.9", "3.10", "3.11", "3.12")
python_latest = python_versions[-1]
PY_VERSIONS = ("3.8", "3.9", "3.10", "3.11", "3.12")
PY_LATEST = PY_VERSIONS[-1]

COV_ARGS = ("coverage", "run", "-m", "--parallel")
PYTEST_ARGS = ("pytest", "-k")

@nox.session(python=python_versions)

@nox.session(python=PY_VERSIONS)
def tests(session: nox.Session) -> None:
"""Run tests on CI/CD pipeline."""
session.install("-e", ".[test]")

session.run(
"coverage",
"run",
"-m",
"--parallel",
"pytest",
"-m",
"not e2e",
*session.posargs,
)
session.run(*COV_ARGS, *PYTEST_ARGS, "not e2e", *session.posargs)


@nox.session(python=python_versions)
@nox.session(python=PY_VERSIONS)
def tests_nocov(session: nox.Session) -> None:
"""Run tests on CI/CD pipeline with no coverage."""
session.install("-e", ".[test]")

session.run("pytest", "-m", "not e2e", *session.posargs)
session.run(*PYTEST_ARGS, "not e2e", *session.posargs)


@nox.session(python=python_latest)
@nox.session(python=PY_LATEST)
def tests_e2e(session: nox.Session) -> None:
"""Run end to end tests on CI/CD pipeline."""
session.install("-e", ".[test]")

session.run(
"coverage",
"run",
"-m",
"--parallel",
"pytest",
"-m",
"e2e",
*session.posargs,
)
session.run(*COV_ARGS, *PYTEST_ARGS, "e2e", *session.posargs)


@nox.session(python=python_latest)
@nox.session(python=PY_LATEST)
def tests_e2e_nocov(session: nox.Session) -> None:
"""Run end to end tests on CI/CD pipeline with no coverage."""
session.install("-e", ".[test]")

session.run("pytest", "-m", "e2e", *session.posargs)
session.run(*PYTEST_ARGS, "e2e", *session.posargs)


@nox.session(python=python_versions, venv_backend="mamba", reuse_venv=True)
@nox.session(python=PY_VERSIONS, venv_backend="mamba", reuse_venv=True)
def tests_mamba(session: nox.Session) -> None:
"""Run tests locally with `mamba` as the backend."""
session.conda_install("--file", "requirements.txt", channel="conda-forge")
session.install("-e", ".[test]")

session.run(
"coverage",
"run",
"-m",
"--parallel",
"pytest",
"-m",
"not e2e",
*session.posargs,
external=True,
)
session.run(*COV_ARGS, *PYTEST_ARGS, "not e2e", *session.posargs)


@nox.session(python=python_versions, venv_backend="mamba", reuse_venv=True)
@nox.session(python=PY_VERSIONS, venv_backend="mamba", reuse_venv=True)
def tests_mamba_nocov(session: nox.Session) -> None:
"""Run tests locally with `mamba` as the backend with no coverage."""
session.conda_install("--file", "requirements.txt", channel="conda-forge")
session.install("-e", ".[test]")

session.run("pytest", "-m", "not e2e", *session.posargs, external=True)
session.run(*PYTEST_ARGS, "not e2e", *session.posargs, external=True)


@nox.session(python=python_latest, venv_backend="mamba", reuse_venv=True)
@nox.session(python=PY_LATEST, venv_backend="mamba", reuse_venv=True)
def tests_mamba_e2e(session: nox.Session) -> None:
"""Run end to end tests locally with `mamba` as the backend."""
session.conda_install("--file", "requirements.txt", channel="conda-forge")
session.install("-e", ".[test]")

session.run(
"coverage",
"run",
"-m",
"--parallel",
"pytest",
"-m",
"e2e",
*session.posargs,
external=True,
)
session.run(*COV_ARGS, *PYTEST_ARGS, "e2e", *session.posargs)


@nox.session(python=python_latest, venv_backend="mamba", reuse_venv=True)
@nox.session(python=PY_LATEST, venv_backend="mamba", reuse_venv=True)
def tests_mamba_e2e_nocov(session: nox.Session) -> None:
"""Run end to end tests locally with `mamba` as the backend with no coverage."""
session.conda_install("--file", "requirements.txt", channel="conda-forge")
session.install("-e", ".[test]")

session.run("pytest", "-m", "e2e", *session.posargs, external=True)
session.run(*PYTEST_ARGS, "e2e", *session.posargs, external=True)


@nox.session(python=python_latest)
@nox.session(python=PY_LATEST)
def coverage(session: nox.Session) -> None:
"""Compile and process coverage reports."""
args = session.posargs or ["report"]
Expand All @@ -146,12 +111,12 @@ def coverage(session: nox.Session) -> None:
file.write(f"### Total coverage: {total}%")


@nox.session(python=python_latest)
@nox.session(python=PY_LATEST)
def lint(session: nox.Session) -> None:
"""Lint package."""
session.install("-e", ".[lint]")

session.run("isort", "-l", "100", ".")
session.run("isort", "--profile", "black", ".")
session.run("black", ".")
session.run("mypy", "bavapi")
session.run("pylint", "bavapi")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "wpp-bavapi"
version = "1.0.2"
version = "1.0.3"
authors = [
{ name = "Ignacio Maiz Vilches", email = "[email protected]" },
]
Expand Down

0 comments on commit 326c4ee

Please sign in to comment.