Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/isort 491 #503

Merged
merged 7 commits into from
Feb 26, 2024
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
159 changes: 90 additions & 69 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,72 +1,93 @@
{
"name": "MyElectricalData development",
"dockerComposeFile": [
"docker-compose.yaml"
],
"shutdownAction": "stopCompose",
"postCreateCommand": "/bin/bash -lc ./.devcontainer/post-install.sh",
// "postCreateCommand": "make init-devcontainer",
"postStartCommand": "make dev",
"service": "workspace",
"workspaceFolder": "/workspace",
"forwardPorts": [],
"customizations": {
"vscode": {
"extensions": [
"mikoz.black-py",
"ms-python.black-formatter",
"genuitecllc.codetogether",
"tamasfe.even-better-toml",
"ms-azuretools.vscode-docker",
"ms-python.flake8",
"mhutchie.git-graph",
"donjayamanne.githistory",
"huizhou.githd",
"github.vscode-github-actions",
"ecmel.vscode-html-css",
"ms-python.isort",
"elagil.pre-commit-helper",
"MarkLarah.pre-commit-vscode",
"ms-python.vscode-pylance",
"ms-python.pylint",
"zeshuaro.vscode-python-poetry",
"the-compiler.python-tox",
"ms-python.python",
"ms-python.debugpy",
"aaron-bond.better-comments",
"ms-vscode-remote.remote-containers",
"ms-vscode.makefile-tools",
"GitHub.copilot"
]
},
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
"python.testing.pytestEnabled": true,
"black-formatter.args": [
"--line-height 119"
],
"editor.wordWrapColumn": 119,
"black-py.useIntegratedTerminal": true,
"git.enableSmartCommit": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"editor.defaultFormatter": "ms-python.black-formatter",
"pylint.cwd": "${workspaceFolder}/src",
"pylint.importStrategy": "fromEnvironment",
"flake8.cwd": "${workspaceFolder}/src",
"flake8.importStrategy": "fromEnvironment",
"editor.wordWrap": "wordWrapColumn",
"python.analysis.autoImportCompletions": false,
"python.analysis.typeCheckingMode": "off",
"python.analysis.extraPaths": [
"./src"
],
"editor.rulers": [ 119 ],
"better-comments.highlightPlainText": true,
"black-formatter.importStrategy": "fromEnvironment",
"editor.defaultFoldingRangeProvider": "ms-python.black-formatter",
"editor.renderWhitespace": "all"
}
"name": "MyElectricalData development",
"dockerComposeFile": ["docker-compose.yaml"],
"shutdownAction": "stopCompose",
"postCreateCommand": "/bin/bash -lc ./.devcontainer/post-install.sh",
// "postCreateCommand": "make init-devcontainer",
"postStartCommand": "make dev",
"service": "workspace",
"workspaceFolder": "/workspace",
"forwardPorts": [],
"customizations": {
"vscode": {
"extensions": [
"mikoz.black-py",
"ms-python.black-formatter",
"genuitecllc.codetogether",
"tamasfe.even-better-toml",
"ms-azuretools.vscode-docker",
"ms-python.flake8",
"mhutchie.git-graph",
"donjayamanne.githistory",
"huizhou.githd",
"github.vscode-github-actions",
"ecmel.vscode-html-css",
"ms-python.isort",
"elagil.pre-commit-helper",
"MarkLarah.pre-commit-vscode",
"ms-python.vscode-pylance",
"ms-python.pylint",
"zeshuaro.vscode-python-poetry",
"the-compiler.python-tox",
"ms-python.python",
"ms-python.debugpy",
"aaron-bond.better-comments",
"ms-vscode-remote.remote-containers",
"ms-vscode.makefile-tools",
"GitHub.copilot",
"ukoloff.win-ca",
"esbenp.prettier-vscode",
"charliermarsh.ruff",
"Gruntfuggly.todo-tree",
"redhat.vscode-yaml"
]
},
"settings": {
"editor.defaultFoldingRangeProvider": "ms-python.black-formatter",
"editor.renderWhitespace": "all",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.wordWrapColumn": 119,
"editor.rulers": [119],
"editor.formatOnSave": true,
"editor.formatOnPaste": true, // CAN SLOWLY VSCODE
"editor.formatOnType": true,
"files.autoSave": "onFocusChange",
"git.enableSmartCommit": true,
"git.autofetch": true,
"window.title": "${rootName}${dirty}${activeEditorShort}${separator}${separator}${profileName}${separator}${appName}",
"http.proxyStrictSSL": false,
// PYTHON
"python.testing.pytestEnabled": true,
"python.analysis.autoImportCompletions": false,
"python.analysis.typeCheckingMode": "off",
"python.analysis.extraPaths": ["./src"],
"python.poetryPath": "/home/cvalentin/.asdf/shims/poetry",
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python3",
"GitHooks.hooksDirectory": "${workspaceFolder}/.git/hooks",
"todo-tree.tree.scanMode": "workspace only",
// PYLINT
"pylint.cwd": "${workspaceFolder}/src",
"pylint.importStrategy": "fromEnvironment",
// FLAKE8
"flake8.cwd": "${workspaceFolder}/src",
"flake8.importStrategy": "fromEnvironment",
// ISORT
"isort.importStrategy": "fromEnvironment",
"isort.check": true,
// BLACK
"black-py.useIntegratedTerminal": true,
"black-formatter.importStrategy": "fromEnvironment",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},
"python.formatting.provider": "none",
// BETTER COMMENT
"better-comments.highlightPlainText": true,
"remote.autoForwardPortsSource": "hybrid",
"github.copilot.advanced": {
"debug.useNodeFetcher": true
}
}
}
}
43 changes: 43 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Flake8 Configuration
[flake8]
# Ignore some flake8-import-order errors
ignore =
# Import statements are in the wrong order.
I100,
# Imported names are in the wrong order.
I101,
# Missing newline between import groups.
I201,
# Additional newline in a group of imports.
I202,
# line break before binary operator
W503,
# line too long
E501,
# Missing docstring in __init__
D107,
# Whitespace before ':'
E203,
# Do not perform function calls in argument defaults.
B008,

exclude =
.tox,
.git,
.venv,
__pycache__,
docs/source/conf.py,
build,
dist,
tests/fixtures/*,
*.pyc,
*.egg-info,
.cache,
.eggs
src/docapi,
tmp

max-complexity = 15
import-order-style = google
application-import-names = flake8
min_python_version = 3.12.2
84 changes: 69 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,80 @@
minimum_pre_commit_version: 3.6.0
fail_fast: true
default_install_hook_types: [pre-commit, commit-msg]
repos:
- repo: https://github.com/espressif/conventional-precommit-linter
rev: v1.3.0 # The version tag you wish to use
hooks:
- id: conventional-precommit-linter
stages: [commit-msg]
args:
- --types=breaking_change,core,build,chore,ci,docs,feat,fix,perf,style,refactor,test, clean
- --subject-min-length=4

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace # Trims trailing whitespace
stages: [pre-commit]
exclude: ^src/docapi/.*|^tests/templates/.*|^src/templates/.*|
- id: check-yaml # Validates YAML files
stages: [pre-commit]
exclude: ^src/docapi/.*|^tests/templates/.*|^src/templates/.*|
- id: check-json # Validates JSON files
stages: [pre-commit]
exclude: ^src/docapi/.*|^tests/templates/.*|^src/templates/.*|
- id: check-added-large-files # Checks for files that are added to the repository that are larger than a threshold
stages: [pre-commit]
exclude: ^src/docapi/.*|^tests/templates/.*|^src/templates/.*|
- id: check-case-conflict # Checks for files that would conflict in case-insensitive filesystems
stages: [pre-commit]
exclude: ^src/docapi/.*|^tests/templates/.*|^src/templates/.*|
- id: check-merge-conflict # Checks for files that contain merge conflict strings
stages: [pre-commit]
exclude: ^src/docapi/.*|^tests/templates/.*|^src/templates/.*|
- id: detect-private-key # Check for the existence of private keys
stages: [pre-commit]
exclude: ^src/docapi/.*|^tests/templates/.*|^src/templates/.*|
- id: check-executables-have-shebangs # Checks that executables have shebangs
stages: [pre-commit]
exclude: ^src/docapi/.*|^tests/templates/.*|^src/templates/.*|
- id: end-of-file-fixer # Makes sure files end in a newline and only a newline
stages: [pre-commit]
exclude: ^src/docapi/.*|^tests/templates/.*|^src/templates/.*|

- repo: local
hooks:
- id: flake8
stages: [pre-commit]
name: flake8
always_run: true
entry: poetry run flake8 .
language: system
types: [python]
pass_filenames: false

- id: black
stages: [pre-commit]
name: black
always_run: true
entry: bash -c 'make black'
entry: poetry run black .
language: system
types: [python]
pass_filenames: false

# - id: flake8
# name: flake8
# always_run: true
# entry: bash -c 'make flake8'
# language: system
# types: [python]
# pass_filenames: false
- id: pylint
stages: [pre-commit]
name: pylint
entry: poetry run pylint .
require_serial: true
language: system
types: [python]
pass_filenames: false

# - id: pylint
# name: pylint
# always_run: true
# entry: bash -c 'make pylint'
# language: system
# types: [python]
# pass_filenames: false
- id: ruff
name: Check python rules enforced with Ruff
entry: poetry run ruff .
require_serial: true
language: system
types: [python]
pass_filenames: false
Loading
Loading