Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ jobs:
$RUNNER_TOOL_CACHE/Python/*
~\AppData\Local\pip\Cache
key: ${{ runner.os }}-build-${{ matrix.python-version }}
- name: install-tox
run: python -m pip install --upgrade tox virtualenv setuptools pip
- name: run-tox
run: tox -e py
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.python-version == '3.8' && matrix.os == 'ubuntu-18.04'
with:
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
- name: install-reqs
run: |
python -m pip install --upgrade tox virtualenv setuptools pip
python -m pip install -U -r requirements-dev.txt
python -m pip install -e .
- name: run-tests
run: pytest tests --cov=100
- name: run-pyrefly
run: pyrefly check nbqa
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:
hooks:
- id: mypy
exclude: ^docs/
additional_dependencies: [types-setuptools, types-toml]
additional_dependencies: [types-setuptools, types-toml, tokenize-rt]
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
Expand Down
7 changes: 5 additions & 2 deletions nbqa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ def _get_configs(cli_args: CLIArgs, project_root: Path) -> Configs:
if getattr(cli_args, section) is not None:
if section == "addopts":
# addopts are added to / overridden rather than replaced outright
config["addopts"] = (*config["addopts"], *getattr(cli_args, section))
config["addopts"] = ( # type: ignore[missing-attribute,unused-ignore]
*config["addopts"],
*getattr(cli_args, section),
)
else:
# TypedDict key must be a string literal
config[section] = getattr(cli_args, section) # type: ignore
Expand Down Expand Up @@ -767,7 +770,7 @@ def _main(cli_args: CLIArgs, configs: Configs) -> int:
for key, i in nb_to_tmp_mapping.items()
if key
not in (
*saved_sources.failed_notebooks,
*saved_sources.failed_notebooks, # type: ignore[not-a-type, unused-ignore]
*saved_sources.non_python_notebooks,
)
],
Expand Down
7 changes: 5 additions & 2 deletions nbqa/path_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
import string
from pathlib import Path
from typing import Any, Dict, Optional, Tuple
from typing import Any, Dict, Optional, Tuple, cast


def remove_prefix(string_: str, prefix: str) -> str:
Expand Down Expand Up @@ -106,7 +106,10 @@ def read_notebook(notebook: str) -> Tuple[Optional[Dict[str, Any]], Optional[boo
config = None

try:
md_content = jupytext.jupytext.read(notebook, config=config)
# jupytext isn't typed unfortunately
md_content = cast( # type: ignore[missing-attribute,unused-ignore]
Any, jupytext.jupytext.read(notebook, config=config)
)
except: # noqa: E72a # pylint: disable=bare-except
return None, None

Expand Down
6 changes: 4 additions & 2 deletions nbqa/replace_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _restore_semicolon(
for idx, token in tokenize_rt.reversed_enumerate(tokens):
if not token.src.strip(" \n") or token.name == "COMMENT":
continue
tokens[idx] = token._replace(src=token.src + ";")
tokens[idx] = token._replace(src=token.src + ";") # type: ignore[missing-attribute,unused-ignore]
break
source = tokenize_rt.tokens_to_src(tokens)
return source
Expand Down Expand Up @@ -226,7 +226,9 @@ def _write_notebook(

for cell in notebook_json["cells"]:
cell["source"] = "".join(cell["source"])
jupytext.jupytext.write(notebook_json, temp_notebook, config=config)
jupytext.jupytext.write( # type: ignore[missing-attribute,unused-ignore]
notebook_json, temp_notebook, config=config
)


def mutate( # pylint: disable=too-many-locals,too-many-arguments
Expand Down
2 changes: 1 addition & 1 deletion nbqa/save_code_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def _has_trailing_semicolon(src: str) -> tuple[str, bool]:
if not token.src.strip(" \n") or token.name == "COMMENT":
continue
if token.name == "OP" and token.src == ";":
tokens[idx] = token._replace(src="")
tokens[idx] = token._replace(src="") # type: ignore[missing-attribute,unused-ignore]
trailing_semicolon = True
break
if not trailing_semicolon:
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pre-commit
pre-commit-hooks
pydocstyle
pylint
pyrefly
pytest
pytest-cov
pytest-randomly
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{38,39,310,311}, docs, docs-links
envlist = pyrefly, py{38,39,310,311}, docs, docs-links

[testenv:docs]
deps = -rdocs/requirements-docs.txt
Expand All @@ -19,3 +19,9 @@ commands =
coverage run -m pytest {posargs:tests -vv -W error}
coverage xml
coverage report --fail-under 100 --show-missing

[testenv:pyrefly]
deps =
-rrequirements-dev.txt
commands =
pyrefly check nbqa