Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace flake8+isort with ruff #3231

Merged
merged 2 commits into from
Jun 23, 2023
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
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