Skip to content

Commit 5ca30aa

Browse files
committed
run pyrefly in CI
1 parent 14593d3 commit 5ca30aa

File tree

8 files changed

+27
-18
lines changed

8 files changed

+27
-18
lines changed

.github/workflows/tox.yml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ jobs:
2626
$RUNNER_TOOL_CACHE/Python/*
2727
~\AppData\Local\pip\Cache
2828
key: ${{ runner.os }}-build-${{ matrix.python-version }}
29-
- name: install-tox
30-
run: python -m pip install --upgrade tox virtualenv setuptools pip
31-
- name: run-tox
32-
run: tox -e py
33-
- name: Upload coverage to Codecov
34-
uses: codecov/codecov-action@v3
35-
if: matrix.python-version == '3.8' && matrix.os == 'ubuntu-18.04'
36-
with:
37-
env_vars: OS,PYTHON
38-
name: codecov-umbrella
39-
fail_ci_if_error: true
29+
- name: install-reqs
30+
run: |
31+
python -m pip install --upgrade tox virtualenv setuptools pip
32+
python -m pip install -U -r requirements/dev.txt
33+
- name: run-tests
34+
run: pytests tests --cov=100
35+
- name: run-pyrefly
36+
run: pyrefly check nbqa

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ repos:
4242
hooks:
4343
- id: mypy
4444
exclude: ^docs/
45-
additional_dependencies: [types-setuptools, types-toml]
45+
additional_dependencies: [types-setuptools, types-toml, tokenize-rt]
4646
- repo: https://github.com/asottile/pyupgrade
4747
rev: v3.19.1
4848
hooks:

nbqa/__main__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,10 @@ def _get_configs(cli_args: CLIArgs, project_root: Path) -> Configs:
460460
if getattr(cli_args, section) is not None:
461461
if section == "addopts":
462462
# addopts are added to / overridden rather than replaced outright
463-
config["addopts"] = (*config["addopts"], *getattr(cli_args, section))
463+
config["addopts"] = ( # type: ignore[missing-attribute,unused-ignore]
464+
*config["addopts"],
465+
*getattr(cli_args, section),
466+
)
464467
else:
465468
# TypedDict key must be a string literal
466469
config[section] = getattr(cli_args, section) # type: ignore

nbqa/path_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def read_notebook(notebook: str) -> Tuple[Optional[Dict[str, Any]], Optional[boo
106106
config = None
107107

108108
try:
109-
md_content = jupytext.jupytext.read(notebook, config=config)
109+
md_content = jupytext.jupytext.read(notebook, config=config) # type: ignore[missing-attribute,unused-ignore]
110110
except: # noqa: E72a # pylint: disable=bare-except
111111
return None, None
112112

nbqa/replace_source.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _restore_semicolon(
5858
for idx, token in tokenize_rt.reversed_enumerate(tokens):
5959
if not token.src.strip(" \n") or token.name == "COMMENT":
6060
continue
61-
tokens[idx] = token._replace(src=token.src + ";")
61+
tokens[idx] = token._replace(src=token.src + ";") # type: ignore[missing-attribute,unused-ignore]
6262
break
6363
source = tokenize_rt.tokens_to_src(tokens)
6464
return source
@@ -226,7 +226,9 @@ def _write_notebook(
226226

227227
for cell in notebook_json["cells"]:
228228
cell["source"] = "".join(cell["source"])
229-
jupytext.jupytext.write(notebook_json, temp_notebook, config=config)
229+
jupytext.jupytext.write( # type: ignore[missing-attribute,unused-ignore]
230+
notebook_json, temp_notebook, config=config
231+
)
230232

231233

232234
def mutate( # pylint: disable=too-many-locals,too-many-arguments

nbqa/save_code_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def _has_trailing_semicolon(src: str) -> tuple[str, bool]:
328328
if not token.src.strip(" \n") or token.name == "COMMENT":
329329
continue
330330
if token.name == "OP" and token.src == ";":
331-
tokens[idx] = token._replace(src="")
331+
tokens[idx] = token._replace(src="") # type: ignore[missing-attribute,unused-ignore]
332332
trailing_semicolon = True
333333
break
334334
if not trailing_semicolon:

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pre-commit
1212
pre-commit-hooks
1313
pydocstyle
1414
pylint
15+
pyrefly
1516
pytest
1617
pytest-cov
1718
pytest-randomly

tox.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py{38,39,310,311}, docs, docs-links
2+
envlist = pyrefly, py{38,39,310,311}, docs, docs-links
33

44
[testenv:docs]
55
deps = -rdocs/requirements-docs.txt
@@ -19,3 +19,9 @@ commands =
1919
coverage run -m pytest {posargs:tests -vv -W error}
2020
coverage xml
2121
coverage report --fail-under 100 --show-missing
22+
23+
[testenv:pyrefly]
24+
deps =
25+
-rrequirements-dev.txt
26+
commands =
27+
pyrefly check nbqa

0 commit comments

Comments
 (0)