Skip to content

A programming framework for agentic AI

pyproject.toml & switch to Ruff (#976)

Jirka Borovec73bb6e7667a6
diff --git a/.flake8 b/.flake8
deleted file mode 100644
index 73f6455d1..000000000
--- a/.flake8
+++ /dev/null
@@ -1,5 +0,0 @@
-[flake8]
-ignore = E203, E266, E501, W503, F403, F401, C901
-max-line-length = 127
-max-complexity = 10
-select = B,C,E,F,W,T4,B9
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 02c10b28f..f0991bd04 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -12,7 +12,7 @@
## Checks
-- [ ] I've used [pre-commit](https://microsoft.github.io/FLAML/docs/Contribute#pre-commit) to lint the changes in this PR, or I've made sure [lint with flake8](https://github.com/microsoft/FLAML/blob/816a82a1155b4de4705b21a615ccdff67c6da379/.github/workflows/python-package.yml#L54-L59) output is two 0s.
+- I've used [pre-commit](https://microsoft.github.io/FLAML/docs/Contribute#pre-commit) to lint the changes in this PR (note the same in integrated in our CI checks).
- [ ] I've included any doc changes needed for https://microsoft.github.io/FLAML/. See https://microsoft.github.io/FLAML/docs/Contribute#documentation to build and test documentation locally.
- [ ] I've added tests (if relevant) corresponding to the changes introduced in this PR.
- [ ] I've made sure all auto checks have passed.
diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml
index 31bff6056..fb1799528 100644
--- a/.github/workflows/python-package.yml
+++ b/.github/workflows/python-package.yml
@@ -82,12 +82,6 @@ jobs:
run: |
# Uninstall pyspark to test env without pyspark
pip uninstall -y pyspark
- - name: Lint with flake8
- run: |
- # stop the build if there are Python syntax errors or undefined names
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
if: (matrix.python-version != '3.7' || matrix.os == 'macos-latest') && matrix.python-version != '3.10'
run: |
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 1ad683e64..1b13a9499 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -7,15 +7,6 @@ ci:
autoupdate_schedule: 'quarterly'
repos:
- - repo: https://github.com/psf/black
- rev: 23.1.0
- hooks:
- - id: black
- args: ["--line-length=120"]
- - repo: https://github.com/pycqa/flake8
- rev: 6.0.0
- hooks:
- - id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
@@ -31,3 +22,12 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: no-commit-to-branch
+ - repo: https://github.com/psf/black
+ rev: 23.3.0
+ hooks:
+ - id: black
+ - repo: https://github.com/charliermarsh/ruff-pre-commit
+ rev: v0.0.261
+ hooks:
+ - id: ruff
+ args: ["--fix"]
diff --git a/flaml/automl/model.py b/flaml/automl/model.py
index 4ea558267..a04f90442 100644
--- a/flaml/automl/model.py
+++ b/flaml/automl/model.py
@@ -2324,10 +2324,7 @@ class HoltWinters(ARIMA):
if self.params["trend"] == "mul" and (train_df.y == 0).sum() > 0:
self.params["trend"] = "add"
- if not self.params["seasonal"] or not self.params["trend"] in [
- "mul",
- "add",
- ]:
+ if not self.params["seasonal"] or self.params["trend"] not in ["mul", "add"]:
self.params["damped_trend"] = False
model = HWExponentialSmoothing(
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 000000000..18038a16f
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,51 @@
+[metadata]
+license_file = "LICENSE"
+description-file = "README.md"
+
+
+[tool.pytest.ini_options]
+addopts = '-m "not conda"'
+markers = [
+ "conda: test related to conda forge distribution"
+]
+
+[tool.black]
+# https://github.com/psf/black
+line-length = 120
+exclude = "(.eggs|.git|.hg|.mypy_cache|.venv|_build|buck-out|build|dist)"
+
+
+[tool.ruff]
+line-length = 120
+# Enable Pyflakes `E` and `F` codes by default.
+select = [
+ "E", "W", # see: https://pypi.org/project/pycodestyle
+ "F", # see: https://pypi.org/project/pyflakes
+# "D", # see: https://pypi.org/project/pydocstyle
+# "N", # see: https://pypi.org/project/pep8-naming
+# "S", # see: https://pypi.org/project/flake8-bandit
+]
+ignore = [
+ "E501",
+ "F401",
+ "F403",
+ "C901",
+]
+# Exclude a variety of commonly ignored directories.
+exclude = [
+ ".eggs",
+ ".git",
+ ".mypy_cache",
+ ".ruff_cache",
+ "__pypackages__",
+ "_build",
+ "build",
+ "dist",
+ "docs"
+]
+ignore-init-module-imports = true
+unfixable = ["F401"]
+
+[tool.ruff.mccabe]
+# Unlike Flake8, default to a complexity level of 10.
+max-complexity = 10
diff --git a/pytest.ini b/pytest.ini
deleted file mode 100644
index 63249c611..000000000
--- a/pytest.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[pytest]
-addopts = -m "not conda"
-markers =
- conda: test related to conda forge distribution
diff --git a/setup.py b/setup.py
index da3207478..c1ff46d70 100644
--- a/setup.py
+++ b/setup.py
@@ -49,7 +49,6 @@ setuptools.setup(
"joblibspark>=0.5.0",
],
"test": [
- "flake8>=3.8.4",
"thop",
"pytest>=6.1.1",
"coverage>=5.3",