Skip to content

Commit

Permalink
Update noxfile.py for lint and code_coverage session (#135)
Browse files Browse the repository at this point in the history
* fix linting errors

* Add type hints

* Update python version

* Implement code_coverage on noxfile.py

* fix linting error

* Update pytest to 7.3.1

* Update CONTRIBUTING.md
  • Loading branch information
youpong authored Apr 22, 2023
1 parent ec667ab commit de6b072
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ You can follow the instructions in the [README](https://github.com/alec-kr/F1PyS
By Default, Nox deletes and recreates virtualenvs every time it is run. If -R option is
specified, reuse virtualenvs and skip re-installation of packages.

linting check:
```
$ poetry run nox -s lint
```

Static type check:
```
$ poetry run nox -s mypy
Expand Down
14 changes: 8 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
"""Sphinx configuration."""

import toml

import os
from typing import List

metadata = toml.load(os.path.join(os.path.dirname(__file__), '..', 'pyproject.toml'))["tool"]["poetry"]
import toml

pyproject_path = os.path.join(os.path.dirname(__file__), '..', 'pyproject.toml')
metadata = toml.load(pyproject_path)["tool"]["poetry"]

project = "F1PyStats"
author = ",".join(metadata["authors"])
Expand All @@ -27,13 +30,12 @@
"sphinx_autodoc_typehints",
]

#templates_path = ['_templates']
exclude_patterns = [] # type: List[str]

# templates_path = ['_templates']
exclude_patterns = [] # type: List[str]


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'furo'
#html_static_path = ['_static']
# html_static_path = ['_static']
33 changes: 20 additions & 13 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""Nox sessoins."""
from nox_poetry import Session
from nox_poetry import session

locations = "f1pystats", "tests", "noxfile.py", "docs/conf.py"
python_versions = ['3.9', '3.10', '3.11']


@session(python=['3.8'])
def lint(session) -> None:
@session(python=python_versions[-1])
def lint(session: Session) -> None:
"""Runs linting for the package."""
args = session.posargs or locations
session.install("flake8",
Expand All @@ -17,36 +20,40 @@ def lint(session) -> None:
session.run("flake8", *args)


@session
def mypy(session) -> None:
@session(python=python_versions)
def mypy(session: Session) -> None:
"""Runs type checking the package."""
args = session.posargs or locations
session.install("mypy",
"types-requests",
"numpy",
"pytest",
"pytest",
"nox_poetry",
"types-toml")
"types-toml")
session.run("mypy", *args)


@session(python=['3.9', '3.10', '3.11'])
def tests(session) -> None:
@session(python=python_versions)
def tests(session: Session) -> None:
"""Run all tests."""
session.install("pytest",
"requests",
"pandas")
session.run("pytest")


@session(python='3.8')
def code_coverage(session) -> None:
@session(python=python_versions[-1])
def code_coverage(session: Session) -> None:
"""Run package coverage."""
pass
session.install("pytest",
"pytest-cov",
"requests",
"pandas")
session.run("pytest", "--cov", "--cov-report=lcov")


@session
def docs(session) -> None:
@session(python=python_versions[-1])
def docs(session: Session) -> None:
"""Build the documentation."""
session.install("sphinx",
"sphinx-autodoc-typehints",
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de6b072

Please sign in to comment.