From 326c4eebe3dcd823be33ec2f3bcb50a6edbaecc9 Mon Sep 17 00:00:00 2001 From: Nacho Maiz Date: Fri, 9 Feb 2024 15:31:15 +0000 Subject: [PATCH] Fix-dtype-conversion-bug * properly catch and handle errors in dtype conversion * simplified and removed repetition in test sessions * version bump --- bavapi/parsing/responses.py | 2 +- docs/release-notes.md | 6 +++ noxfile.py | 85 +++++++++++-------------------------- pyproject.toml | 2 +- 4 files changed, 33 insertions(+), 62 deletions(-) diff --git a/bavapi/parsing/responses.py b/bavapi/parsing/responses.py index ce58585..1dca759 100644 --- a/bavapi/parsing/responses.py +++ b/bavapi/parsing/responses.py @@ -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") diff --git a/docs/release-notes.md b/docs/release-notes.md index 116b6c2..435f77d 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -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 diff --git a/noxfile.py b/noxfile.py index b5db67c..cd257b0 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,4 +1,4 @@ -# pylint: disable=import-outside-toplevel, invalid-name +# pylint: disable=import-outside-toplevel """Package tooling session definitions for `nox`""" @@ -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"] @@ -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") diff --git a/pyproject.toml b/pyproject.toml index 53be2fe..c614f4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = "ignacio.maiz@bavgroup.com" }, ]