Skip to content

Commit

Permalink
devcontainer style improvements (#358)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
bpkroth and motus authored May 15, 2023
1 parent a96c231 commit e5a8bde
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 64 deletions.
59 changes: 33 additions & 26 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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",
"eamodio.gitlens",
"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",
"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
"matangover.mypy",
"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
"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"
]
}
}
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"editorconfig": true,
"trailingComma": "es5"
}
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
49 changes: 26 additions & 23 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -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",
"eamodio.gitlens",
"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",
"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
"matangover.mypy",
"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
"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 changes: 12 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos-3.10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos-3.11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos-3.8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos-3.9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter
Expand Down
1 change: 1 addition & 0 deletions conda-envs/mlos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- pycodestyle
- autopep8
- pydocstyle
- flake8
- setuptools
- setuptools-scm
- jupyter
Expand Down
4 changes: 2 additions & 2 deletions mlos_bench/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
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'],
Expand Down
10 changes: 5 additions & 5 deletions mlos_core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
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)
}
Expand All @@ -52,10 +52,10 @@
'': ['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',
],
Expand Down
5 changes: 1 addition & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e5a8bde

Please sign in to comment.