Skip to content
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: 0 additions & 2 deletions .flake8

This file was deleted.

2 changes: 1 addition & 1 deletion .github/instructions/python.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async def process_users(
### Code Style & Formatting

* Follow [Python Coding Conventions](../../docs/coding-conventions.md) **strictly**.
* Format code with `black` and `ruff`.
* Format code with `ruff`.
* Lint code with `ruff` and `pylint`.

### Library Compatibility
Expand Down
12 changes: 0 additions & 12 deletions .isort.cfg

This file was deleted.

38 changes: 11 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@ fail_fast: false
default_language_version:
python: python3.13
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.14.10
hooks:
# Run the linter.
- id: ruff-check
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-added-large-files
args: ["--maxkb=1024"]
- id: check-merge-conflict
- id: check-yaml
- id: check-json
- id: check-toml
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
Expand All @@ -20,32 +31,6 @@ repos:
args: [--allow-missing-credentials]
- id: debug-statements
- id: no-commit-to-branch
# NOTE: Keep order as pyupgrade (will update code) then pycln (remove unused imports), then isort (sort them) and black (final formatting)
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
args:
- "--py313-plus"
name: upgrade code
exclude: ^scripts/maintenance/computational-clusters/autoscaled_monitor/cli\.py$ # Optional get replaced and typer does not like it
- repo: https://github.com/hadialqattan/pycln
rev: v2.6.0
hooks:
- id: pycln
args: [--all, --expand-stars]
name: prune imports
- repo: https://github.com/PyCQA/isort
rev: 7.0.0
hooks:
- id: isort
args: ["--profile", "black"]
name: sort imports
- repo: https://github.com/psf/black
rev: 25.11.0
hooks:
- id: black
name: black format code
- repo: local
hooks:
- id: pytest-testit
Expand All @@ -65,4 +50,3 @@ repos:
hooks:
- id: typos
name: spellchecker
continue_on_error: true
64 changes: 56 additions & 8 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@

lint.select = [
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]


line-length = 120
indent-width = 4
target-version = "py313"

[lint]
select = [
"A", # [https://pypi.org/project/flake8-builtins/]
"ARG", # [https://pypi.org/project/flake8-unused-arguments/]
"ASYNC", # [https://pypi.org/project/flake8-async/]
Expand Down Expand Up @@ -40,17 +76,20 @@ lint.select = [
"W", # [https://pypi.org/project/pycodestyle/] warnings
"YTT", # [https://pypi.org/project/flake8-2020/]
]
lint.ignore = [
"E501", # line too long, handled by black
ignore = [
"S101", # use of `assert` detected hanbled by pylance, does not support noseq
"TID252", # [*] Relative imports from parent modules are banned
"TRY300", # Checks for return statements in try blocks. SEE https://beta.ruff.rs/docs/rules/try-consider-else/
]

target-version = "py313"
# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[lint.per-file-ignores]
[per-file-ignores]
"**/{tests,pytest_simcore}/**" = [
"T201", # print found
"ARG001", # unused function argument
Expand All @@ -59,7 +98,6 @@ target-version = "py313"
"PLR0913", # too many arguments
"N806", # Uppercase variables in functions
"PT001", # use pytest.fixture over pytest.fixture() whatsoever
"PT004", # does not return anything, add leading underscore
"ERA001", # found commented out code
"FBT001", # Boolean positional arg in function definition
]
Expand All @@ -69,5 +107,15 @@ fixture-parentheses = false
parametrize-names-type = "csv"


[lint.pylint]
max-args = 10
[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
"eamodio.gitlens",
"exiasr.hadolint",
"ms-azuretools.vscode-containers",
"ms-python.black-formatter",
"ms-python.pylint",
"ms-python.python",
"njpwerner.autodocstring",
"samuelcolvin.jinjahtml",
"timonwong.shellcheck",
"vscode-icons-team.vscode-icons",
"vscode-icons-team.vscode-icons"
]
}
6 changes: 0 additions & 6 deletions .vscode/launch.template.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// This is a template. Clone and replace extension ".template.json" by ".json"
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
Expand Down Expand Up @@ -44,7 +40,6 @@
"justMyCode": false
},
{
// This test adds --external-envfile and expects a file named ".secrets" in the workspace root.
"name": "Python: Test w/ repo.config",
"type": "debugpy",
"request": "launch",
Expand All @@ -65,7 +60,6 @@
"justMyCode": false
},
{
// This tests enables the httpx spy and dumps captures in a json. Mainly for api-server
"name": "Python: Test-Httpx-Spy",
"type": "debugpy",
"request": "launch",
Expand Down
5 changes: 3 additions & 2 deletions .vscode/settings.template.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// This is a template. Clone and replace extension ".template.json" by ".json"
{
"autoDocstring.docstringFormat": "pep257",
"editor.tabSize": 2,
Expand Down Expand Up @@ -54,7 +53,9 @@
],
"[python]": {
"editor.detectIndentation": false,
"editor.tabSize": 4
"editor.tabSize": 4,
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff"
},
"[makefile]": {
"editor.insertSpaces": false
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ To enable GitHub Actions on your forked repository:

### Code styles and conventions

Current setup: [ESLint](https://eslint.org) for `JavaScript` and [Black](https://black.readthedocs.io/en/stable/) + [Pylint](https://www.pylint.org) for `Python`. Have a look in the project root for individual configuration files.
Current setup: [ESLint](https://eslint.org) for `JavaScript` and [Ruff](https://docs.astral.sh/ruff/) + [Pylint](https://www.pylint.org) for `Python`. Have a look in the project root for individual configuration files.

Read more at [Coding Conventions and Linters](docs/coding-conventions.md).

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</p>

<!-- BADGES: LINKS ON CLICK --------------------------------------------------------------->
[![black_badge]](https://github.com/psf/black)
[![ruff_badge]](https://github.com/astral-sh/ruff)
[![ci_badge]](https://github.com/ITISFoundation/osparc-simcore/actions/workflows/ci-testing-deploy.yml)
[![codecov_badge]](https://codecov.io/gh/ITISFoundation/osparc-simcore)
[![doc_badge]](https://itisfoundation.github.io/)
Expand All @@ -18,7 +18,7 @@
[![s4l_status]](https://s4llite.statuspage.io)

<!-- BADGES: LINKS TO IMAGES. Default to https://shields.io/ ------------------------------>
[black_badge]:https://img.shields.io/badge/code%20style-black-000000.svg
[ruff_badge]:https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
[ci_badge]:https://github.com/ITISFoundation/osparc-simcore/actions/workflows/ci-testing-deploy.yml/badge.svg
[codecov_badge]:https://codecov.io/gh/ITISFoundation/osparc-simcore/branch/master/graph/badge.svg?token=h1rOE8q7ic
[doc_badge]:https://img.shields.io/website-up-down-green-red/https/itisfoundation.github.io.svg?label=documentation
Expand Down
5 changes: 2 additions & 3 deletions docs/coding-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_it(something: Something, create_something: Callable[..., Something]):
In short we use the following naming convention ( roughly [PEP8](https://peps.python.org/pep-0008/) ):

| | example |
| -------- | --------------------------------------------- |
|----------|-----------------------------------------------|
| Function | `function`, `my_fun­ction` |
| Variable | `x`, `var`, `my_variable` |
| Class | `Model`, `MyClass` |
Expand All @@ -94,7 +94,7 @@ In short we use the following naming convention ( roughly [PEP8](https://peps.p

### For the rest ... (tools)

- [black] will enforce the style: Just use it.
- [ruff] will enforce the style: Just use it.
- [pylint] will check the some extra conventions: see [.pylintrc](../.pylintrc).
- ``make pylint`` recipe available on ``packages`` or ``services``
- [mypy] is a type-checker that will check syntax : see [mypy.ini](../mypy.ini)
Expand Down Expand Up @@ -131,7 +131,6 @@ Have a look at `ESLint`'s configuration files [.eslintrc.json](.eslintrc.json) a

<!-- Keep the space below here for a SORTED list of references -->

[black]:https://black.readthedocs.io/en/stable/index.html
[mypy-doc]:https://mypy.readthedocs.io/en/latest/
[mypy]:https://www.mypy-lang.org/
[pep257]:https://peps.python.org/pep-0257/
Expand Down
2 changes: 1 addition & 1 deletion packages/models-library/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ docker_rest_api.py: ## auto-generates pydantic models for Docker REST API models
--output $@

# formats
@black $@
@ruff format $@
# copy output to src/models_library/generated_models...
@mkdir --parents src/models_library/generated_models
@mv $@ src/models_library/generated_models/$@
Expand Down
Empty file modified packages/postgres-database/docker/entrypoint.bash
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion packages/service-integration/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ _compose_spec_model_autogenerated.py: compose-spec.json ## auto-generates pydant
--input $< \
--output $@
# formats and moves
black $@
ruff format $@
mv $@ src/service_integration/$@

generate-compose-spec-model: _compose_spec_model_autogenerated.py ## generates pydantic model for compose-specification
Expand Down
Empty file modified scripts/helpers/logger.bash
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion scripts/openapi/openapi_python_server_codegen.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#/bin/bash
#!/bin/bash
cd $(dirname $0)
usage()
{
Expand Down
6 changes: 3 additions & 3 deletions services/web/server/docker/healthcheck.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@
from urllib.request import urlopen

SUCCESS, UNHEALTHY = 0, 1

HTTP_OK = 200
# Disabled if boots with debugger
ok = os.environ.get("SC_BOOT_MODE", "").lower() == "debug"

# Queries host
# pylint: disable=consider-using-with
ok = (
ok
or urlopen(
or urlopen( # noqa: S310
"{host}{baseurl}".format(
host=sys.argv[1], baseurl=os.environ.get("SIMCORE_NODE_BASEPATH", "")
) # adds a base-path if defined in environ
).getcode()
== 200
== HTTP_OK
)

sys.exit(SUCCESS if ok else UNHEALTHY)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"studies_access_enabled": 0
},
"tracing": {
"enabled": 1,
"enabled": 1
},
"db": {
"postgres": {
Expand Down
Loading