Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

chore: Ruff improvements #46

Merged
merged 5 commits into from
Dec 4, 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
42 changes: 21 additions & 21 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ algokit-utils = "^1.3"
python-dotenv = "^1.0.0"

[tool.poetry.group.dev.dependencies]
ruff = ">=0.0.260"
ruff = "^0.1.6"
black = {extras = ["d"], version = "^22.10.0"}
flake8 = "^6.0.0"
pytest = "^7.2.2"
Expand All @@ -29,11 +29,25 @@ build-backend = "poetry.core.masonry.api"
select = ["E", "F", "ANN", "UP", "N", "C4", "B", "A", "YTT", "W", "FBT", "Q", "RUF", "I"]
extend-exclude = [
"tests_generated/*", # Ignoring generated tests, ruff specific errors are to be caught by pytest
"template_content"
"template_content",
".git",
".mypy_cache",
".ruff_cache",
]
ignore = [
"ANN101", # no type for self
"ANN102", # no type for cls
"RET505", # allow else after return
"SIM108", # allow if-else in place of ternary
"E111", # indentation is not a multiple of four
"E117", # over-indented
"ISC001", # single line implicit string concatenation
"ISC002", # multi line implicit string concatenation
"Q000", # bad quotes inline string
"Q001", # bad quotes multiline string
"Q002", # bad quotes docstring
"Q003", # avoidable escaped quotes
"W191", # indentation contains tabs
]
unfixable = ["B", "RUF"]

Expand Down
3 changes: 2 additions & 1 deletion template_content/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ python-dotenv = "^1.0.0"
black = {extras = ["d"], version = "*"}
{% endif -%}
{% if python_linter == 'ruff' -%}
ruff = ">=0.0.260"
ruff = "^0.1.6"
{% elif python_linter == 'flake8' -%}
flake8 = "*"
{% endif -%}
Expand All @@ -39,6 +39,7 @@ build-backend = "poetry.core.masonry.api"

{% if python_linter == 'ruff' -%}
[tool.ruff]
line-length = 120
select = ["E", "F", "ANN", "UP", "N", "C4", "B", "A", "YTT", "W", "FBT", "Q", "RUF", "I"]
ignore = [
"ANN101", # no type for self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
{% if use_python_mypy -%}
"matangover.mypy",
{% endif -%}
{% if use_python_black -%}
"ms-python.black-formatter",
{% endif -%}
{% if deployment_language == 'typescript' -%}
"esbenp.prettier-vscode",
{% endif -%}
"bungcip.better-toml",
"tamasfe.even-better-toml",
"editorconfig.editorconfig"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,35 @@
// Prevent default import sorting from running; Ruff will sort imports for us anyway
"source.organizeImports": false
},
"editor.defaultFormatter": null
{% if use_python_black -%}
"editor.defaultFormatter": "ms-python.black-formatter",
{% else -%}
"editor.defaultFormatter": null,
{% endif -%}
},
{% if use_python_pytest -%}
"python.testing.pytestEnabled": true,
{% endif -%}
{% if use_python_black -%}
"python.formatting.provider": "black",
"black-formatter.args": ["--config=pyproject.toml"],
{% endif -%}
{% if python_linter != 'none' -%}
"python.linting.pylintEnabled": false,
{% if use_python_pytest -%}
"python.testing.pytestEnabled": true,
{% endif -%}
{% if python_linter == 'flake8' -%}
"python.linting.flake8Enabled": true,
"flake8.importStrategy": "fromEnvironment",
"flake8.args": ["--config=.flake8"],
{% endif -%}
{% if python_linter == 'ruff' -%}
"ruff.enable": true,
"ruff.lint.run": "onSave",
"ruff.lint.args": ["--config=pyproject.toml"],
"ruff.importStrategy": "fromEnvironment",
"ruff.fixAll": true, //lint and fix all files in workspace
"ruff.organizeImports": true, //organize imports on save
"ruff.codeAction.disableRuleComment": {
"enable": true
},
"ruff.codeAction.fixViolation": {
"enable": true
},
{% endif -%}
{% if use_python_mypy -%}
"python.analysis.typeCheckingMode": "off",
Expand Down
7 changes: 0 additions & 7 deletions tests_generated/test_default_parameters/.copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@ author_email: None
author_name: None
contract_name: hello_world
deployment_language: python
negar-abbasi marked this conversation as resolved.
Show resolved Hide resolved
ide_jetbrains: false
ide_vscode: true
indexer_port: 8980
indexer_server: http://localhost
indexer_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
preset_name: starter
project_name: test_default_parameters
python_linter: none
use_dispenser: false
use_github_actions: false
use_pre_commit: false
use_python_black: true
use_python_mypy: false
use_python_pip_audit: true
negar-abbasi marked this conversation as resolved.
Show resolved Hide resolved
use_python_pytest: true

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"recommendations": [
"ms-python.python",
"bungcip.better-toml",
"ms-python.black-formatter",
"tamasfe.even-better-toml",
"editorconfig.editorconfig"
]
}
6 changes: 3 additions & 3 deletions tests_generated/test_default_parameters/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
// Prevent default import sorting from running; Ruff will sort imports for us anyway
"source.organizeImports": false
},
"editor.defaultFormatter": null
},
"editor.defaultFormatter": "ms-python.black-formatter",
},
"black-formatter.args": ["--config=pyproject.toml"],
"python.testing.pytestEnabled": true,
"python.formatting.provider": "black",

// On Windows, if execution policy is set to Signed (default) then it won't be able to activate the venv
// so instead let's set it to RemoteSigned for VS Code terminal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@ author_email: None
author_name: None
contract_name: hello_world
deployment_language: python
ide_jetbrains: false
ide_vscode: true
indexer_port: 8980
indexer_server: http://localhost
indexer_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
preset_name: starter
project_name: test_deployment_language-python
python_linter: none
use_dispenser: false
use_github_actions: false
use_pre_commit: false
use_python_black: true
use_python_mypy: false
use_python_pip_audit: true
use_python_pytest: true

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"recommendations": [
"ms-python.python",
"bungcip.better-toml",
"ms-python.black-formatter",
"tamasfe.even-better-toml",
"editorconfig.editorconfig"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
// Prevent default import sorting from running; Ruff will sort imports for us anyway
"source.organizeImports": false
},
"editor.defaultFormatter": null
},
"editor.defaultFormatter": "ms-python.black-formatter",
},
"black-formatter.args": ["--config=pyproject.toml"],
"python.testing.pytestEnabled": true,
"python.formatting.provider": "black",

// On Windows, if execution policy is set to Signed (default) then it won't be able to activate the venv
// so instead let's set it to RemoteSigned for VS Code terminal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@ author_email: None
author_name: None
contract_name: hello_world
deployment_language: typescript
ide_jetbrains: false
ide_vscode: true
indexer_port: 8980
indexer_server: http://localhost
indexer_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
preset_name: starter
project_name: test_deployment_language-typescript
python_linter: none
use_dispenser: false
use_github_actions: false
use_pre_commit: false
use_python_black: true
use_python_mypy: false
use_python_pip_audit: true
use_python_pytest: true

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"recommendations": [
"ms-python.python",
"ms-python.black-formatter",
"esbenp.prettier-vscode",
"bungcip.better-toml",
"tamasfe.even-better-toml",
"editorconfig.editorconfig"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
// Prevent default import sorting from running; Ruff will sort imports for us anyway
"source.organizeImports": false
},
"editor.defaultFormatter": null
},
"editor.defaultFormatter": "ms-python.black-formatter",
},
"black-formatter.args": ["--config=pyproject.toml"],
"python.testing.pytestEnabled": true,
"python.formatting.provider": "black",

// On Windows, if execution policy is set to Signed (default) then it won't be able to activate the venv
// so instead let's set it to RemoteSigned for VS Code terminal
Expand Down
7 changes: 0 additions & 7 deletions tests_generated/test_ide_jetbrains-False/.copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@ author_email: None
author_name: None
contract_name: hello_world
deployment_language: python
ide_jetbrains: false
ide_vscode: true
indexer_port: 8980
indexer_server: http://localhost
indexer_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
preset_name: starter
project_name: test_ide_jetbrains-False
python_linter: none
use_dispenser: false
use_github_actions: false
use_pre_commit: false
use_python_black: true
use_python_mypy: false
use_python_pip_audit: true
use_python_pytest: true

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"recommendations": [
"ms-python.python",
"bungcip.better-toml",
"ms-python.black-formatter",
"tamasfe.even-better-toml",
"editorconfig.editorconfig"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
// Prevent default import sorting from running; Ruff will sort imports for us anyway
"source.organizeImports": false
},
"editor.defaultFormatter": null
},
"editor.defaultFormatter": "ms-python.black-formatter",
},
"black-formatter.args": ["--config=pyproject.toml"],
"python.testing.pytestEnabled": true,
"python.formatting.provider": "black",

// On Windows, if execution policy is set to Signed (default) then it won't be able to activate the venv
// so instead let's set it to RemoteSigned for VS Code terminal
Expand Down
7 changes: 0 additions & 7 deletions tests_generated/test_ide_jetbrains-True/.copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@ author_email: None
author_name: None
contract_name: hello_world
deployment_language: python
ide_jetbrains: true
ide_vscode: true
indexer_port: 8980
indexer_server: http://localhost
indexer_token: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
preset_name: starter
project_name: test_ide_jetbrains-True
python_linter: none
use_dispenser: false
use_github_actions: false
use_pre_commit: false
use_python_black: true
use_python_mypy: false
use_python_pip_audit: true
use_python_pytest: true

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"recommendations": [
"ms-python.python",
"bungcip.better-toml",
"ms-python.black-formatter",
"tamasfe.even-better-toml",
"editorconfig.editorconfig"
]
}
6 changes: 3 additions & 3 deletions tests_generated/test_ide_jetbrains-True/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
// Prevent default import sorting from running; Ruff will sort imports for us anyway
"source.organizeImports": false
},
"editor.defaultFormatter": null
},
"editor.defaultFormatter": "ms-python.black-formatter",
},
"black-formatter.args": ["--config=pyproject.toml"],
"python.testing.pytestEnabled": true,
"python.formatting.provider": "black",

// On Windows, if execution policy is set to Signed (default) then it won't be able to activate the venv
// so instead let's set it to RemoteSigned for VS Code terminal
Expand Down
Loading