Skip to content

Commit

Permalink
Merge pull request #8 from pappasam/fix-dev
Browse files Browse the repository at this point in the history
Lots of upgrades to dev environment
  • Loading branch information
pappasam committed Sep 23, 2023
2 parents 6eba4cd + a330c96 commit 9a434a5
Show file tree
Hide file tree
Showing 9 changed files with 819 additions and 840 deletions.
32 changes: 10 additions & 22 deletions .github/workflows/serdataclasses-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
name: serdelicacy ci

on: [push]

jobs:
build:
runs-on: ubuntu-18.04

runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.8']
poetry-version: ['1.0.0b7']
pip-version: ['19.3.1']

python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Setup, Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Tox, Python ${{ matrix.python-version }}
- name: Nox, Python ${{ matrix.python-version }}
run: |
# Python
python -m pip install --upgrade pip==${{ matrix.pip-version }}
# Poetry
curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py > get-poetry.py
python get-poetry.py --preview
rm get-poetry.py
source $HOME/.poetry/env
poetry self update --preview ${{ matrix.poetry-version }}
# Tox
pip install tox==3.14.1
tox -e py
pip install poetry==1.6.1
poetry install
poetry run nox -s lint
poetry run nox -s typecheck
poetry run nox -s pytest
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ setup: ## Set up the local development environment
poetry install -E docs
poetry run pre-commit install

.PHONY: tox
test: ## Run the tests
poetry run tox

.PHONY: publish
publish: ## Build & publish the new version
poetry build
Expand All @@ -30,3 +26,19 @@ serve-docs: build-docs ## Simple development server for Sphinx docs
.PHONY: open-docs
open-docs: ## Open Sphinx docs index in a browser
gio open docs/_build/html/index.html

.PHONY: fix
fix: ## Fix all files in-place
poetry run nox -s $@

.PHONY: lint
lint: ## Run linters on all files
poetry run nox -s $@

.PHONY: typecheck
typecheck: ## Run static type checks
poetry run nox -s $@

.PHONY: pytest
pytest: ## Run unit tests
poetry run nox -s $@
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[mypy]
python_version = 3.8
python_version = 3.11
33 changes: 33 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Configure nox for automated tests."""

import nox

NOX_SESSION = nox.session(python=False)


@NOX_SESSION
def fix(session: nox.Session):
"""Fix files inplace."""
session.run("ruff", "check", "-se", "--fix", ".")
session.run("black", "-q", ".")
session.run("isort", "-q", "--overwrite-in-place", ".")
session.run("docformatter", "--in-place", "--recursive", ".")


@NOX_SESSION
def lint(session: nox.Session):
"""Check file formatting that only have to do with formatting."""
session.run("ruff", "check", ".")
session.run("black", "--check", "--diff", ".")
session.run("isort", "--check", ".")
session.run("docformatter", "--check", "--recursive", ".")


@NOX_SESSION
def typecheck(session: nox.Session):
session.run("mypy", "serdelicacy")


@NOX_SESSION
def pytest(session: nox.Session):
session.run("pytest", "tests")
1,511 changes: 732 additions & 779 deletions poetry.lock

Large diffs are not rendered by default.

41 changes: 11 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,36 +37,17 @@ sphinx-rtd-theme = { version = "^0.5.0", optional = true }
m2r2 = { version = "^0.2.7", optional = true }
toml = { version = "^0.10.2", optional = true }

[tool.poetry.dev-dependencies]
black = "20.8b1"
hypothesis = "^4.44.1"
isort = "^5.6.4"
mypy = "^0.790"
pre-commit = "^1.20.0"
pylint = "^2.6.0"
pytest = "^5.2.2"
toml-sort = "^0.16.1"
tox = "^3.14.1"
tox-asdf = "^0.1.0"
docformatter = "^1.3.1"
[tool.poetry.group.dev.dependencies]
black = ">=22.1.0"
hypothesis = ">=4.44.1"
isort = ">=5.6.4"
mypy = ">=0.790"
pre-commit = ">=1.20.0"
pytest = ">=5.2.2"
toml-sort = ">=0.16.1"
docformatter = ">=1.3.1"
nox = ">=2023.4.22"
ruff = ">=0.0.291"

[tool.poetry.extras]
docs = ["Sphinx", "sphinx-rtd-theme", "m2r2", "toml"]

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py38
isolated_build = true
skipsdist = true
[testenv]
platform = linux
whitelist_externals = poetry
skip_install = true
commands =
poetry install
poetry run black --check --diff serdelicacy tests
poetry run mypy serdelicacy
poetry run pylint serdelicacy tests
poetry run pytest -vv
"""
12 changes: 12 additions & 0 deletions serdelicacy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@
from .overrides import Override
from .serialize import dump
from .typedefs import OptionalProperty, get, is_missing

__all__ = [
"load",
"DeserializeError",
"SerdeError",
"SerializeError",
"Override",
"dump",
"OptionalProperty",
"get",
"is_missing",
]
4 changes: 2 additions & 2 deletions serdelicacy/deserialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def _check_initvar_instance(self) -> PossibleResult[T]:
def _check_none(self) -> PossibleResult[T]:
"""Checks if a result is None."""
if self.constructor == type(None):
if not self.obj is None:
if self.obj is not None:
raise DeserializeError(
type(None), self.obj, self.new_depth, self.key
)
Expand All @@ -481,7 +481,7 @@ def _check_undefined(self) -> PossibleResult[T]:
included here for completeness sake.
"""
if self.constructor == Missing:
if not self.obj is MISSING:
if self.obj is not MISSING:
raise DeserializeError(
Missing, self.obj, self.new_depth, self.key
)
Expand Down
4 changes: 2 additions & 2 deletions serdelicacy/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from dataclasses import dataclass, field
from typing import Any, Callable, NoReturn, TypeVar, Union

T = TypeVar("T") # pylint: disable=invalid-name
T = TypeVar("T")


def _noreturn(value: Any) -> NoReturn: # pylint: disable=unused-argument
def _noreturn(value: Any) -> None:
"""Simple 1 argument function that returns nothing."""


Expand Down

0 comments on commit 9a434a5

Please sign in to comment.