Skip to content

Commit

Permalink
precommit: upgraded ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Oct 4, 2024
1 parent 1fb20f2 commit 4c81b58
Show file tree
Hide file tree
Showing 237 changed files with 185 additions and 324 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-master-backoffice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request_target:
branches: [master]
paths:
- 'backoffice-repo/backoffice/**'
- 'backoffice/**'

jobs:
lint:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pull-request-master-inspirehep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
pull_request_target:
branches: [master]
paths-ignore:
- 'backoffice-repo/**'
- 'backoffice/**'
- 'workflows/**'

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-master-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request_target:
branches: [master]
paths:
- "backoffice-repo/workflows/**"
- "workflows/**"
jobs:
lint:
uses: ./.github/workflows/lint.yml
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-backoffice.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
with:
ref: ${{ inputs.ref }}
image: cern-sis/inspire/backoffice
context: ./backoffice-repo/backoffice
dockerfile: ./backoffice-repo/backoffice/Dockerfile
context: ./backoffice
dockerfile: ./backoffice/Dockerfile
secrets: inherit

test:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
ref: ${{ inputs.ref }}

- name: Test
working-directory: ./backoffice-repo/backoffice
working-directory: ./backoffice
run: >
docker run
--pull always
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
with:
ref: ${{ inputs.ref }}
image: cern-sis/inspire/workflows
context: ./backoffice-repo/workflows
dockerfile: ./backoffice-repo/workflows/Dockerfile
context: ./workflows
dockerfile: ./workflows/Dockerfile
secrets: inherit
test:
needs: build
Expand All @@ -44,7 +44,7 @@ jobs:
ref: ${{ inputs.ref }}

- name: Test
working-directory: ./backoffice-repo/workflows
working-directory: ./workflows
run: >
docker run
--network=host
Expand Down
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,23 @@ target/
#vscode
.vscode

# Celery stuff
celerybeat-schedule
celerybeat.pid

# macOS
.DS_Store
*.orig
.localstack

# Airflow stuff:
workflows/logs/

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
files: ^(backend|backoffice-repo)/
files: ^(backend|backoffice|workflows)/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
Expand All @@ -12,7 +12,7 @@ repos:
args: [ --pytest-test-first ]
exclude: '^(?!factories/)'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
rev: v0.6.8
hooks:
- id: ruff
args: [ --fix ]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set the AIRFLOW_HOME environment variable
export AIRFLOW_HOME=$(shell pwd)/backoffice-repo/workflows
export AIRFLOW_HOME=$(shell pwd)/workflows
export AIRFLOW_PROJ_DIR=$(AIRFLOW_HOME)

sleep:
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/integration-async/cds/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
import requests_mock


@pytest.fixture()
@pytest.fixture
def inspire_app_with_config_for_cds_sync(inspire_app, override_config):
with override_config(
FEATURE_FLAG_ENABLE_CDS_SYNC=True, CDS_SERVER_API="http://localhost:9876/api/"
):
yield inspire_app


@pytest.fixture()
@pytest.fixture
def inspire_app_for_cds_sync(inspire_app_with_config_for_cds_sync):
with requests_mock.Mocker() as mocker:
mocker.get(
Expand Down
18 changes: 9 additions & 9 deletions backend/tests/integration-async/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def celery_session_app(app, celery_session_app):
return celery_session_app


@pytest.fixture()
@pytest.fixture
def clean_celery_session(celery_session_app, celery_session_worker):
celery_session_app.control.purge()
yield celery_session_worker
Expand All @@ -99,7 +99,7 @@ def celery_config():
return {}


@pytest.fixture()
@pytest.fixture
def cli(inspire_app):
"""Click CLI runner inside the Flask application."""
runner = CliRunner()
Expand All @@ -108,7 +108,7 @@ def cli(inspire_app):
return runner


@pytest.fixture()
@pytest.fixture
def redis(inspire_app):
redis_url = inspire_app.config.get("CACHE_REDIS_URL")
redis = StrictRedis.from_url(redis_url, decode_responses=True)
Expand All @@ -118,7 +118,7 @@ def redis(inspire_app):
redis.close()


@pytest.fixture()
@pytest.fixture
def override_config(inspire_app):
@contextmanager
def _override_config(**kwargs):
Expand All @@ -143,18 +143,18 @@ def _override_config(**kwargs):
return _override_config


@pytest.fixture()
@pytest.fixture
def inspire_app(app, cache):
return app


@pytest.fixture()
@pytest.fixture
def enable_self_citations(inspire_app, override_config):
with override_config(FEATURE_FLAG_ENABLE_SELF_CITATIONS=True):
yield inspire_app


@pytest.fixture()
@pytest.fixture
def enable_disambiguation(inspire_app, override_config):
with override_config(
FEATURE_FLAG_ENABLE_AUTHOR_DISAMBIGUATION=True,
Expand All @@ -164,13 +164,13 @@ def enable_disambiguation(inspire_app, override_config):
yield inspire_app


@pytest.fixture()
@pytest.fixture
def enable_files(inspire_app, override_config):
with override_config(FEATURE_FLAG_ENABLE_FILES=True):
yield inspire_app


@pytest.fixture()
@pytest.fixture
def s3(inspire_app, enable_files):
mock = mock_s3()
mock.start()
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/integration-async/editor/test_editor_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from tenacity import stop_after_delay, wait_fixed


@pytest.fixture()
@pytest.fixture
def record_with_two_revisions(inspire_app, clean_celery_session):
record_data = {
"$schema": "http://localhost:5000/schemas/records/hep.json",
Expand All @@ -36,7 +36,7 @@ def record_with_two_revisions(inspire_app, clean_celery_session):
return record["control_number"]


@pytest.fixture()
@pytest.fixture
def hidden_record_with_two_revisions(inspire_app, clean_celery_session):
record_data = {
"$schema": "http://localhost:5000/schemas/records/hep.json",
Expand Down
10 changes: 5 additions & 5 deletions backend/tests/integration/config/test_views_suggesters.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ def test_author_suggesters(inspire_app):
assert result_rec_id == expected_rec_id


@pytest.mark.xfail()
@pytest.mark.xfail
def test_jobs_suggester():
raise NotImplementedError("Missing serializer")


@pytest.mark.xfail()
@pytest.mark.xfail
def test_journals_suggesters():
raise NotImplementedError("Missing serializer")


@pytest.mark.xfail()
@pytest.mark.xfail
def test_experiments_suggesters():
raise NotImplementedError("Missing serializer")

Expand Down Expand Up @@ -191,11 +191,11 @@ def test_seminars_series_name_suggester_ignores_duplicates(inspire_app):
assert suggestion_count == 1


@pytest.mark.xfail()
@pytest.mark.xfail
def test_data_suggesters():
raise NotImplementedError("Missing serializer")


@pytest.mark.xfail()
@pytest.mark.xfail
def test_institutions_suggesters():
raise NotImplementedError("Missing serializer")
30 changes: 15 additions & 15 deletions backend/tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,31 +50,31 @@ def app_config(app_config):
return app_config


@pytest.fixture()
@pytest.fixture
def enable_files(inspire_app, override_config):
with override_config(FEATURE_FLAG_ENABLE_FILES=True):
yield inspire_app


@pytest.fixture()
@pytest.fixture
def disable_files(inspire_app, override_config):
with override_config(FEATURE_FLAG_ENABLE_FILES=False):
yield inspire_app


@pytest.fixture()
@pytest.fixture
def enable_self_citations(inspire_app, override_config):
with override_config(FEATURE_FLAG_ENABLE_SELF_CITATIONS=True):
yield inspire_app


@pytest.fixture()
@pytest.fixture
def enable_hal_push(inspire_app, override_config):
with override_config(FEATURE_FLAG_ENABLE_HAL_PUSH=True):
yield inspire_app


@pytest.fixture()
@pytest.fixture
def disable_hal_push(inspire_app, override_config):
with override_config(FEATURE_FLAG_ENABLE_HAL_PUSH=False):
yield inspire_app
Expand All @@ -95,7 +95,7 @@ def database(appctx):
db_.session.remove()


@pytest.fixture()
@pytest.fixture
def db_(database):
"""Creates a new database session for a test.
Scope: function
Expand Down Expand Up @@ -138,18 +138,18 @@ def restart_savepoint(sess, trans):
database.session = old_session


@pytest.fixture()
@pytest.fixture
def db(db_):
return db_


@pytest.fixture()
@pytest.fixture
def es_clear(es):
es_cleanup(es)
return es


@pytest.fixture()
@pytest.fixture
def cli(inspire_app):
"""Click CLI runner inside the Flask application."""
runner = CliRunner()
Expand All @@ -158,7 +158,7 @@ def cli(inspire_app):
return runner


@pytest.fixture()
@pytest.fixture
def redis(inspire_app):
redis_url = inspire_app.config.get("CACHE_REDIS_URL")
redis = StrictRedis.from_url(redis_url, decode_responses=True)
Expand All @@ -168,14 +168,14 @@ def redis(inspire_app):
redis.close()


@pytest.fixture()
@pytest.fixture
def inspire_app(base_app, db, es_clear, vcr_config):
# Make sure the API app has the same config
base_app.wsgi_app.mounts["/api"].config.update(base_app.config)
return base_app


@pytest.fixture()
@pytest.fixture
def override_config(inspire_app):
@contextmanager
def _override_config(**kwargs):
Expand All @@ -200,7 +200,7 @@ def _override_config(**kwargs):
return _override_config


@pytest.fixture()
@pytest.fixture
def s3(inspire_app, enable_files):
mock = mock_s3()
mock.start()
Expand All @@ -219,7 +219,7 @@ class MockedInspireS3:
inspire_app.extensions["inspirehep-s3"] = real_inspirehep_s3


@pytest.fixture()
@pytest.fixture
def _mocked_inspire_snow(mocker):
# If SNOW_AUTH_URL (and SNOW_CLIENT_ID, SNOW_CLIENT_SECRET) is set, we dont need to mock the token
if not current_app.config.get("SNOW_AUTH_URL"):
Expand All @@ -234,7 +234,7 @@ def _mocked_inspire_snow(mocker):
mocker.patch("inspirehep.snow.api.InspireSnow.get_token", return_value="abcd")


@pytest.fixture()
@pytest.fixture
def _teardown_cache():
yield
current_cache.delete("snow_users")
Expand Down
Loading

0 comments on commit 4c81b58

Please sign in to comment.