devcontainer style improvements (#358)

* Disable line buffering
* fail pylint checks on unused-import errors
* make sure pycodestyle checks for indentation
* increase code quality requirements
* add some new extensions
* bring pycodestyle checks inline with flake8
* add a prettier rc that instructs it to use our editorconfig

---------

Co-authored-by: Sergiy Matusevych <sergiym@microsoft.com>
This commit is contained in:
Brian Kroth 2023-05-15 17:19:20 -05:00 коммит произвёл GitHub
Родитель a96c231e04
Коммит e5a8bde5a5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 93 добавлений и 66 удалений

Просмотреть файл

@ -8,7 +8,9 @@
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
// Prep some host side things for the container build
"initializeCommand": [".devcontainer/scripts/prep-container-build"],
"initializeCommand": [
".devcontainer/scripts/prep-container-build"
],
// Make sure the container user can read/write to the package caches.
"onCreateCommand": "sudo -n mkdir -p /opt/conda/pkgs/cache /var/cache/pip && sudo -n chown -R vscode /opt/conda/pkgs/cache /var/cache/pip",
// Make sure the conda env is up to date with the source tree expectations.
@ -43,40 +45,45 @@
"python.defaultInterpreterPath": "/opt/conda/envs/mlos/bin/python",
"python.testing.pytestPath": "/opt/conda/envs/mlos/bin/pytest",
"python.linting.pylintPath": "/opt/conda/envs/mlos/bin/pylint",
"pylint.path": ["/opt/conda/envs/mlos/bin/pylint"],
"pylint.path": [
"/opt/conda/envs/mlos/bin/pylint"
],
"python.linting.flake8Path": "/opt/conda/envs/mlos/bin/flake8",
"python.linting.mypyPath": "/opt/conda/envs/mlos/bin/mypy",
"mypy.dmypyExecutable": "/opt/conda/envs/mlos/bin/dmypy",
"mypy.runUsingActiveInterpreter": false
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"EditorConfig.EditorConfig",
"streetsidesoftware.code-spell-checker",
"ms-python.vscode-pylance",
"ms-python.python",
"ms-python.pylint",
"matangover.mypy",
"davidanson.vscode-markdownlint",
"donjayamanne.githistory",
"donjayamanne.python-environment-manager",
"njpwerner.autodocstring",
"ms-toolsai.jupyter",
"lextudio.restructuredtext",
"trond-snekvik.simple-rst",
"DavidAnson.vscode-markdownlint", // Linter for markdown files
"huntertran.auto-markdown-toc", // Auto-generated Markdown Table of Contents
"github.vscode-github-actions", // GitHub Actions integration
"ms-azuretools.vscode-docker",
"waderyan.gitblame", // Enhances git blame experience
"donjayamanne.githistory", // Enhanced git history experience
"eamodio.gitlens",
"ms-vsliveshare.vsliveshare", // Allows easy code share
"Gruntfuggly.todo-tree", // Highlights TODO comments in code
"github.copilot", // Copilot integration
"IBM.output-colorizer", // Colorize your output/test logs
"hashicorp.terraform", // Terraform syntax highlighting
"redhat.vscode-yaml", // Kubernetes manifest syntax highlighting
"stkb.rewrap", // "Alt + Q" -> rewrap comments after n characters on one line
"tyriar.sort-lines", // "Ctrl + Shift + P -> Sort lines" -> sort lines alphabetically
"esbenp.prettier-vscode" // A pretty good formatter for many languages
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"github.copilot",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"gruntfuggly.todo-tree",
"hashicorp.terraform",
"huntertran.auto-markdown-toc",
"ibm.output-colorizer",
"lextudio.restructuredtext",
"matangover.mypy",
"ms-azuretools.vscode-docker",
"ms-python.autopep8",
"ms-python.flake8",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vsliveshare.vsliveshare",
"njpwerner.autodocstring",
"redhat.vscode-yaml",
"stkb.rewrap",
"streetsidesoftware.code-spell-checker",
"trond-snekvik.simple-rst",
"tyriar.sort-lines",
"waderyan.gitblame"
]
}
}

4
.prettierrc Normal file
Просмотреть файл

@ -0,0 +1,4 @@
{
"editorconfig": true,
"trailingComma": "es5"
}

Просмотреть файл

@ -8,7 +8,7 @@ fail-under=9.8
# See Also: https://github.com/PyCQA/pydocstyle/issues/309#issuecomment-1426642147
# Also fail on unused imports.
fail-on=
C0116,
missing-function-docstring,
unused-import
# Ignore pylint complaints about an upstream dependency.

51
.vscode/extensions.json поставляемый
Просмотреть файл

@ -1,30 +1,33 @@
{
"recommendations": [
"EditorConfig.EditorConfig",
"streetsidesoftware.code-spell-checker",
"ms-python.vscode-pylance",
"ms-python.python",
"ms-python.pylint",
"matangover.mypy",
"davidanson.vscode-markdownlint",
"donjayamanne.githistory",
"donjayamanne.python-environment-manager",
"njpwerner.autodocstring",
"lextudio.restructuredtext",
"trond-snekvik.simple-rst",
"DavidAnson.vscode-markdownlint", // Linter for markdown files
"huntertran.auto-markdown-toc", // Auto-generated Markdown Table of Contents
"github.vscode-github-actions", // GitHub Actions integration
"ms-azuretools.vscode-docker",
"waderyan.gitblame", // Enhances git blame experience
"donjayamanne.githistory", // Enhanced git history experience
"eamodio.gitlens",
"ms-vsliveshare.vsliveshare", // Allows easy code share
"Gruntfuggly.todo-tree", // Highlights TODO comments in code
"github.copilot", // Copilot integration
"IBM.output-colorizer", // Colorize your output/test logs
"hashicorp.terraform", // Terraform syntax highlighting
"redhat.vscode-yaml", // Kubernetes manifest syntax highlighting
"stkb.rewrap", // "Alt + Q" -> rewrap comments after n characters on one line
"tyriar.sort-lines", // "Ctrl + Shift + P -> Sort lines" -> sort lines alphabetically
"esbenp.prettier-vscode" // A pretty good formatter for many languages
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
"github.copilot",
"github.vscode-github-actions",
"github.vscode-pull-request-github",
"gruntfuggly.todo-tree",
"hashicorp.terraform",
"huntertran.auto-markdown-toc",
"ibm.output-colorizer",
"lextudio.restructuredtext",
"matangover.mypy",
"ms-azuretools.vscode-docker",
"ms-python.autopep8",
"ms-python.flake8",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vsliveshare.vsliveshare",
"njpwerner.autodocstring",
"redhat.vscode-yaml",
"stkb.rewrap",
"streetsidesoftware.code-spell-checker",
"trond-snekvik.simple-rst",
"tyriar.sort-lines",
"waderyan.gitblame"
]
}

14
.vscode/settings.json поставляемый
Просмотреть файл

@ -10,7 +10,8 @@
"python.linting.pylintEnabled": true,
"python.linting.pycodestyleEnabled": true,
"python.linting.pydocstyleEnabled": true,
"python.linting.mypyEnabled": false, // use the dmypy daemon extension instead - it's faster
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": false, // use the dmypy daemon extension instead - it's faster
// "mypy.runUsingActiveInterpreter": true, // in the devcontainer we override this to use an explicit path
"autoDocstring.docstringFormat": "numpy",
"json.validate.enable": true,
@ -50,5 +51,14 @@
"--ignore D001"
],
"esbonio.sphinx.confDir": "${workspaceFolder}/doc/source",
"esbonio.sphinx.buildDir": "${workspaceFolder}/doc/build/"
"esbonio.sphinx.buildDir": "${workspaceFolder}/doc/build/",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"python.formatting.provider": "none",
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "modifications"
}
}

Просмотреть файл

@ -19,7 +19,7 @@ MKDIR_BUILD := $(shell test -d build || mkdir build)
# Run make in parallel by default.
MAKEFLAGS += -j$(shell nproc)
MAKEFLAGS += -Oline
#MAKEFLAGS += -Oline
.PHONY: all
all: check test dist dist-test doc licenseheaders

Просмотреть файл

@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter

Просмотреть файл

@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter

Просмотреть файл

@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter

Просмотреть файл

@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter

Просмотреть файл

@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter

Просмотреть файл

@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter

Просмотреть файл

@ -18,14 +18,14 @@ try:
from setuptools_scm import get_version
version = get_version(root='..', relative_to=__file__)
if version is not None:
_VERSION = version
_VERSION = version # noqa: F811
except ImportError:
warning("setuptools_scm not found, using version from _version.py")
except LookupError as e:
warning(f"setuptools_scm failed to find git version, using version from _version.py: {e}")
extra_requires: Dict[str, List[str]] = {
extra_requires: Dict[str, List[str]] = { # pylint: disable=consider-using-namedtuple-or-dataclass
# Additional tools for extra functionality.
'azure': ['azure-storage-file-share'],
'storage-sql-duckdb': ['sqlalchemy', 'duckdb_engine'],

Просмотреть файл

@ -18,14 +18,14 @@ try:
from setuptools_scm import get_version
version = get_version(root='..', relative_to=__file__)
if version is not None:
_VERSION = version
_VERSION = version # noqa: F811
except ImportError:
warning("setuptools_scm not found, using version from _version.py")
except LookupError as e:
warning(f"setuptools_scm failed to find git version, using version from _version.py: {e}")
extra_requires: Dict[str, List[str]] = {
extra_requires: Dict[str, List[str]] = { # pylint: disable=consider-using-namedtuple-or-dataclass
'emukit': ['emukit'],
'skopt': ['scikit-optimize<=0.9.0'], # FIXME: temporarily work around some version mismatch issues (PR 850)
}
@ -52,10 +52,10 @@ setup(
'': ['py.typed', '**/*.pyi'],
},
install_requires=[
'scikit-learn<1.2', # FIXME: temporarily work around some version mismatch issues (PR 850)
'joblib>=1.1.1', # CVE-2022-21797: scikit-learn dependency, addressed in 1.2.0dev0, which isn't currently released
'scikit-learn<1.2', # FIXME: temporarily work around some version mismatch issues (PR 850)
'joblib>=1.1.1', # CVE-2022-21797: scikit-learn dependency, addressed in 1.2.0dev0, which isn't currently released
'scipy>=1.3.2',
'numpy<1.24', # FIXME: temporarily work around some version mismatch issues (PR 850)
'numpy<1.24', # FIXME: temporarily work around some version mismatch issues (PR 850)
'pandas>=1.0.3',
'ConfigSpace>=0.6.1',
],

Просмотреть файл

@ -4,12 +4,9 @@ universal = 1
[pycodestyle]
count = True
# E124: Closing bracket does not match indentation of opening bracket's line
# E261: At least two spaces before inline comment
# E502: The backslash is redundant between brackets
# W503: Line break occurred before a binary operator
# W504: Line break occurred after a binary operator
ignore = E124,E261,E502,W503,W504
ignore = W503,W504
format = pylint
# See Also: .editorconfig, .pylintrc
max-line-length = 132