Skip to content

Commit

Permalink
Merge pull request #1124 from bouthilx/fix-pre-commit
Browse files Browse the repository at this point in the history
Try switching from flake8 to ruff
  • Loading branch information
bouthilx authored Nov 17, 2023
2 parents d51e6ea + 9b47459 commit d524331
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: 3.11
- run: pip install pre-commit
- run: pre-commit --version
- run: pre-commit install
Expand Down Expand Up @@ -255,7 +257,7 @@ jobs:
name: codecov-umbrella
fail_ci_if_error: false
pypi:
needs: [test, backward-compatibility, test-long-algos, mongodb, test_no_extras, test-dashboard-build]
needs: [test, backward-compatibility, test-long-algos, mongodb, test_no_extras] # , test-dashboard-build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -349,7 +351,7 @@ jobs:
user: __token__
password: ${{ secrets.pypi_password }}
conda:
needs: [test, backward-compatibility, test-long-algos, test-dashboard-build]
needs: [test, backward-compatibility, test-long-algos] #, test-dashboard-build]
runs-on: ubuntu-latest
env:
ANACONDA_TOKEN: ${{ secrets.anaconda_token }}
Expand Down
12 changes: 5 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ repos:
hooks:
- id: codespell
args: ["--skip", "*.html,*.ipynb,dashboard/src/.yarn/**,dashboard/src/yarn.lock,dashboard/build/**,dashboard/src/src/__tests__/**", "--ignore-words-list=hist,wont,ro"]
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: flake8
- id: ruff
args:
- --ignore=E203,E402,E712,E722,E731,E741,F401,F403,F405,F524,F841,W503,E302,E704
- --max-complexity=30
- --max-line-length=456
- --ignore=E203,E402,E712,E722,E731,E741,F401,F403,F405,F524,F841
- --line-length=300
- --show-source
- --statistics
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions src/orion/algo/nevergradoptimizer/nevergradoptimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def _(dim: Fidelity):
"OptimisticNoisyOnePlusOne",
"Powell",
"CmaFmin2",
"FCMA",
"RPowell",
"RSQP",
"PymooNSGA2",
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/algo/long/nevergrad/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def merge_dicts(*dicts: dict) -> dict:
"DiscreteOnePlusOne": _deterministic_first_point,
"EDA": _no_tell_without_ask,
"ES": {},
"FCMA": {},
"GeneticDE": {},
"HaltonSearch": _deterministic_points,
"HaltonSearchPlusMiddlePoint": _deterministic_points,
Expand Down Expand Up @@ -218,6 +217,7 @@ def merge_dicts(*dicts: dict) -> dict:
"NGOpt14": {},
"NGOpt21": {},
"NGOpt38": {},
"FCMA": _not_serializable,
}


Expand Down
8 changes: 4 additions & 4 deletions tests/unittests/algo/test_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def test_init_with_default_value(self):
"""Make sure the default value is set"""
dim = Real("yolo", "uniform", -3, 10, default_value=2.0)

assert type(dim.default_value) is float
assert isinstance(dim.default_value, float)

def test_set_outside_bounds_default_value(self):
"""Make sure default value is inside the bounds"""
Expand Down Expand Up @@ -440,7 +440,7 @@ def test_init_with_default_value(self):
"""Make sure the type of the default value is int"""
dim = Integer("yolo", "uniform", -3, 10, default_value=2)

assert type(dim.default_value) is int
assert isinstance(dim.default_value, int)

def test_set_outside_bounds_default_value(self):
"""Make sure the default value is inside the bounds of the dimensions"""
Expand Down Expand Up @@ -588,14 +588,14 @@ def test_init_with_default_value_string(self):
categories = {"asdfa": 0.1, 2: 0.2, 3: 0.3, "lalala": 0.4}
dim = Categorical("yolo", categories, default_value="asdfa")

assert type(dim.default_value) is str
assert isinstance(dim.default_value, str)

def test_init_with_default_value_int(self):
"""Make sure the default value is of the correct type"""
categories = {"asdfa": 0.1, 2: 0.2, 3: 0.3, "lalala": 0.4}
dim = Categorical("yolo", categories, default_value=2)

assert type(dim.default_value) is int
assert isinstance(dim.default_value, int)

def test_init_with_wrong_default_value(self):
"""Make sure the default value exists"""
Expand Down
8 changes: 4 additions & 4 deletions tests/unittests/benchmark/task/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_call(self):
assert callable(task)

objectives = task([1, 2])
assert type(objectives[0]) == dict
assert isinstance(objectives[0], dict)

def test_search_space(self):
"""Test to get task search space"""
Expand All @@ -45,7 +45,7 @@ def test_call(self):
assert callable(task)

objectives = task([1, 2])
assert type(objectives[0]) == dict
assert isinstance(objectives[0], dict)

def test_search_space(self):
"""Test to get task search space"""
Expand All @@ -70,7 +70,7 @@ def test_call(self):
assert callable(task)

objectives = task([1, 2])
assert type(objectives[0]) == dict
assert isinstance(objectives[0], dict)

def test_search_space(self):
"""Test to get task search space"""
Expand All @@ -95,7 +95,7 @@ def test_call(self):
assert callable(task)

objectives = task([1, 2])
assert type(objectives[0]) == dict
assert isinstance(objectives[0], dict)

def test_search_space(self):
"""Test to get task search space"""
Expand Down

0 comments on commit d524331

Please sign in to comment.