<commit_before>[tox]
envlist =
    bandit
    build
    doc8
    docs
    etl
    flake8
    linters
    nbval
    pre-commit
    release
    scripts
    testrelease
    ci
    validate
    unit

[testenv]
whitelist_externals =
    bash
    coverage
# shared directory for re-used packages
envdir = {toxinidir}/.env_pudl
passenv =
    CI
    HOME
    GITHUB_*
    API_KEY_EIA
    GOOGLE_APPLICATION_CREDENTIALS

###########################################################################
###########################################################################
# Code and Documentation Linters
###########################################################################
###########################################################################

###########################################################################
# Run the full suite of flake8 linters on the codebase
[testenv:flake8]
skip_install = true
deps =
    flake8
    flake8-builtins
    flake8-colors
    flake8-docstrings
    flake8-rst-docstrings
    flake8-use-fstring
    mccabe
    pep8-naming
    pycodestyle
    pydocstyle
    pyflakes
commands =
    flake8 --config .flake8 src/pudl/ test/ setup.py

###########################################################################
# Lint the documentation input files for syntactical correctness
[testenv:doc8]
skip_install = true
deps =
    sphinx
    doc8
commands =
    doc8 docs/

###########################################################################
# Run all the pre-commit hooks that aren't covered by the other linters
[testenv:pre-commit]
skip_install = true
deps =
    pre-commit
commands =
    pre-commit run --all-files --show-diff-on-failure python-no-eval
    pre-commit run --all-files --show-diff-on-failure python-no-log-warn
    pre-commit run --all-files --show-diff-on-failure python-check-blanket-noqa
    pre-commit run --all-files --show-diff-on-failure check-merge-conflict
    pre-commit run --all-files --show-diff-on-failure check-yaml
    pre-commit run --all-files --show-diff-on-failure check-case-conflict
    pre-commit run --all-files --show-diff-on-failure debug-statements
    pre-commit run --all-files --show-diff-on-failure name-tests-test

[testenv:bandit]
skip_install = true
deps =
    bandit
commands =
    bandit -r src/pudl/ -c .bandit.yml

###########################################################################
# Run all of the code linters that we've set up above.
[testenv:linters]
skip_install = true
deps =
    {[testenv:pre-commit]deps}
    {[testenv:bandit]deps}
    {[testenv:flake8]deps}
commands =
    {[testenv:pre-commit]commands}
    {[testenv:bandit]commands}
    {[testenv:flake8]commands}

###########################################################################
###########################################################################
# Test code, build docs, validate data
###########################################################################
###########################################################################

###########################################################################
# Test the ETL processing pipeline:
# * Without any arguments, this will try to download and process *all* data
# * If you just want to do one year, you need to pass --fast to pytest
# * If you don't want it to download, you need to pass --pudl_in=AUTO
[testenv:etl]
extras =
    test
commands =
    pytest {posargs} \
      --cov={envsitepackagesdir}/pudl \
      --cov-append \
      --cov-report=term \
      --cov-report=xml \
      --cov-config=.coveragerc \
      test/etl_test.py \
      test/glue_test.py \
      test/fast_output_test.py \
      test/zenodo_datapackage_test.py

# Runs unit tests under src/pudl and unit tests specifically identified under test/
[testenv:unit]
extras =
    test
commands =
    pytest \
      --cov={envsitepackagesdir}/pudl \
      --cov-append \
      --cov-report=xml \
      --cov-config=.coveragerc \
      test/unit

###########################################################################
# Run the full suite of data validation tests.
# This requires a *fully* populated PUDL database
[testenv:validate]
skip_install = false
extras =
    test
commands =
    pytest \
      --live_pudl_db=AUTO \
      --live_ferc1_db=AUTO \
      --pudl_in=AUTO \
      --pudl_out=AUTO \
      test/validate

###########################################################################
# Validate the JupyterLab Notebooks that we are trying to keep functional
[testenv:nbval]
skip_install = false<commit_msg>Include doctest modules in tox unit tests<commit_after>[tox]
envlist =
    bandit
    build
    doc8
    docs
    etl
    flake8
    linters
    nbval
    pre-commit
    release
    scripts
    testrelease
    ci
    validate
    unit

[testenv]
whitelist_externals =
    bash
    coverage
# shared directory for re-used packages
envdir = {toxinidir}/.env_pudl
passenv =
    CI
    HOME
    GITHUB_*
    API_KEY_EIA
    GOOGLE_APPLICATION_CREDENTIALS

###########################################################################
###########################################################################
# Code and Documentation Linters
###########################################################################
###########################################################################

###########################################################################
# Run the full suite of flake8 linters on the codebase
[testenv:flake8]
skip_install = true
deps =
    flake8
    flake8-builtins
    flake8-colors
    flake8-docstrings
    flake8-rst-docstrings
    flake8-use-fstring
    mccabe
    pep8-naming
    pycodestyle
    pydocstyle
    pyflakes
commands =
    flake8 --config .flake8 src/pudl/ test/ setup.py

###########################################################################
# Lint the documentation input files for syntactical correctness
[testenv:doc8]
skip_install = true
deps =
    sphinx
    doc8
commands =
    doc8 docs/

###########################################################################
# Run all the pre-commit hooks that aren't covered by the other linters
[testenv:pre-commit]
skip_install = true
deps =
    pre-commit
commands =
    pre-commit run --all-files --show-diff-on-failure python-no-eval
    pre-commit run --all-files --show-diff-on-failure python-no-log-warn
    pre-commit run --all-files --show-diff-on-failure python-check-blanket-noqa
    pre-commit run --all-files --show-diff-on-failure check-merge-conflict
    pre-commit run --all-files --show-diff-on-failure check-yaml
    pre-commit run --all-files --show-diff-on-failure check-case-conflict
    pre-commit run --all-files --show-diff-on-failure debug-statements
    pre-commit run --all-files --show-diff-on-failure name-tests-test

[testenv:bandit]
skip_install = true
deps =
    bandit
commands =
    bandit -r src/pudl/ -c .bandit.yml

###########################################################################
# Run all of the code linters that we've set up above.
[testenv:linters]
skip_install = true
deps =
    {[testenv:pre-commit]deps}
    {[testenv:bandit]deps}
    {[testenv:flake8]deps}
commands =
    {[testenv:pre-commit]commands}
    {[testenv:bandit]commands}
    {[testenv:flake8]commands}

###########################################################################
###########################################################################
# Test code, build docs, validate data
###########################################################################
###########################################################################

###########################################################################
# Test the ETL processing pipeline:
# * Without any arguments, this will try to download and process *all* data
# * If you just want to do one year, you need to pass --fast to pytest
# * If you don't want it to download, you need to pass --pudl_in=AUTO
[testenv:etl]
extras =
    test
commands =
    pytest {posargs} \
      --cov={envsitepackagesdir}/pudl \
      --cov-append \
      --cov-report=term \
      --cov-report=xml \
      --cov-config=.coveragerc \
      test/etl_test.py \
      test/glue_test.py \
      test/fast_output_test.py \
      test/zenodo_datapackage_test.py

# Runs unit tests under src/pudl and unit tests specifically identified under test/
[testenv:unit]
extras =
    test
commands =
    pytest \
      --cov={envsitepackagesdir}/pudl \
      --cov-append \
      --cov-report=xml \
      --cov-config=.coveragerc \
      --doctest-modules {envsitepackagesdir}/pudl \
      test/unit

###########################################################################
# Run the full suite of data validation tests.
# This requires a *fully* populated PUDL database
[testenv:validate]
skip_install = false
extras =
    test
commands =
    pytest \
      --live_pudl_db=AUTO \
      --live_ferc1_db=AUTO \
      --pudl_in=AUTO \
      --pudl_out=AUTO \
      test/validate

###########################################################################
# Validate the JupyterLab Notebooks that we are trying to keep functional
[testenv:nbval]
skip_install = false
{'fraction_non_alphanumeric': 0.31913270865112225, 'fraction_numerical': 0.004140335585094792, 'mean_word_length': 3.8133193497640274, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '26872', 'n_tokens_mistral': 2650, 'n_tokens_neox': 2556, 'n_words': 619}