Skip to content

Commit

Permalink
Replace flake8+isort with ruff (#3231)
Browse files Browse the repository at this point in the history
* Replace flake8+isort with ruff

* Update github action
  • Loading branch information
fritzo committed Jun 23, 2023
1 parent e20a65c commit ea44053
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel 'setuptools!=58.5.*,<60'
pip install flake8 black isort>=5.0 mypy nbstripout nbformat
pip install ruff black mypy nbstripout nbformat
- name: Lint
run: |
make lint
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ tutorial: FORCE
$(MAKE) -C tutorial html

lint: FORCE
flake8
ruff check .
black --check *.py pyro examples tests scripts profiler
isort --check .
python scripts/update_headers.py --check
mypy --install-types --non-interactive pyro scripts

license: FORCE
python scripts/update_headers.py

format: license FORCE
ruff check --fix .
black *.py pyro examples tests scripts profiler
isort .

version: FORCE
python scripts/update_version.py
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tool.ruff]
line-length = 120
ignore = ["E741", "E721"]
select = ["E", "F", "I"]
3 changes: 1 addition & 2 deletions pyro/contrib/funsor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

import pyroapi

from pyro.contrib.funsor.handlers import condition, do, markov
from pyro.contrib.funsor.handlers import condition, do, markov, vectorized_markov
from pyro.contrib.funsor.handlers import plate as _plate
from pyro.contrib.funsor.handlers import vectorized_markov
from pyro.contrib.funsor.handlers.primitives import to_data, to_funsor
from pyro.primitives import (
clear_param_store,
Expand Down
4 changes: 2 additions & 2 deletions pyro/distributions/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
# isort: split

import torch
from torch.distributions.constraints import Constraint
from torch.distributions.constraints import __all__ as torch_constraints
from torch.distributions.constraints import (
Constraint,
independent,
lower_cholesky,
positive,
positive_definite,
)
from torch.distributions.constraints import __all__ as torch_constraints


# TODO move this upstream to torch.distributions
Expand Down
2 changes: 1 addition & 1 deletion pyro/poutine/messenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __enter__(self):
Derived versions cannot be overridden to take arguments
and must always return self.
"""
if not (self in _PYRO_STACK):
if self not in _PYRO_STACK:
# if this poutine is not already installed,
# put it on the bottom of the stack.
_PYRO_STACK.append(self)
Expand Down
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,26 @@
"test": EXTRAS_REQUIRE
+ [
"black>=21.4b0",
"flake8",
"nbval",
"pytest>=5.0",
"pytest-cov",
"pytest>=5.0",
"ruff",
"scipy>=1.1",
],
"profile": ["prettytable", "pytest-benchmark", "snakeviz"],
"dev": EXTRAS_REQUIRE
+ [
"black>=21.4b0",
"flake8",
"isort>=5.0",
"mypy>=0.812",
"nbformat",
"nbsphinx>=0.3.2",
"nbstripout",
"nbval",
"ninja",
"pypandoc",
"pytest>=5.0",
"pytest-xdist",
"pytest>=5.0",
"ruff",
"scipy>=1.1",
"sphinx",
"sphinx_rtd_theme",
Expand Down

0 comments on commit ea44053

Please sign in to comment.