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

Chore: improve lints and vscode settings #658

Merged
merged 8 commits into from
Mar 12, 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
23 changes: 23 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"recommendations": [
//
//-- Used for IDE, Workbench, Tools --------------------------------------------
//
"editorconfig.editorconfig",
"VisualStudioExptTeam.vscodeintellicode",
//
//-- Used for linters, formatters ----------------------------------------------
//
"ms-python.python",
"ms-python.vscode-pylance",
"charliermarsh.ruff",
"njpwerner.autodocstring",
"njqdev.vscode-python-typehint",
// "ms-python.mypy-type-checker",
//
//-- Used for: Git, Code Quality -----------------------------------------------
//
"vivaxy.vscode-conventional-commits",
"codezombiech.gitignore"
]
Fixed Show fixed Hide fixed
}
50 changes: 44 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,55 @@
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug File",
"type": "python",
"name": "python: with Args",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
"args": "${input:arguments}",
"cwd": "${input:debug_working_dir}",
"justMyCode": true,
"autoReload": {
"enable": true
}
},
{
"name": "Python: Module",
"type": "python",
"name": "python: Within Libs",
"type": "debugpy",
"request": "launch",
"module": "petl"
"program": "${file}",
"args": "${input:last_arguments}",
"cwd": "${input:debug_working_dir}",
"justMyCode": false,
"autoReload": {
"enable": true
}
}
],
Fixed Show fixed Hide fixed
"inputs": [
{
// Usage: "args": "${input:arguments}",
"id": "arguments",
"type": "promptString",
"description": "Which arguments to pass to the command?"
},
Fixed Show fixed Hide fixed
{
// Usage: "cwd": "${input:debug_working_dir}"
"id": "debug_working_dir",
"type": "pickString",
"description": "Debug the python program in which of these folders?",
"options": [
"${fileDirname}",
"${fileWorkspaceFolder}",
"${fileWorkspaceFolder}/petl",
"${fileWorkspaceFolder}/petl/tests",
"${fileWorkspaceFolder}/examples",
"${relativeFileDirname}",
"${userHome}",
"${cwd}",
"${selectedText}",
""
],
"default": "${fileDirname}"
},
]
}
126 changes: 89 additions & 37 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,121 @@
{
// SETTINGS OF EDITOR FOR ALL FILES
"editor.formatOnSave": false, // for reducing git changes for now
//-- Editor settings for all files -------------------------------------------------
//
"editor.formatOnSave": false, // Using this for reducing git changes between commits
"editor.formatOnPaste": true,
"editor.tabSize": 4,
"editor.wordWrapColumn": 83,
"editor.renderWhitespace": "trailing",
"editor.renderWhitespace": "boundary",
"files.eol": "\n",
"files.encoding": "utf8",
//
//-- Editor settings for search/view files -----------------------------------------
//
"files.exclude": {
// python
"**/.tox": true,
"**/.nox": true,
"**/.eggs": true,
"**/*.egg-info": true,
"**/__pycache__": true,
"**/__pypackages__": true,
"**/.pylint.d": true,
"**/.cache": true,
"**/.mypy_cache": true,
"**/.pytest_cache": true,
"**/.ruff_cache": true,
"**/.ipynb_checkpoints": true,
"**/*.pyc": true,
"**/*.egg": true,
"**/*.pyenv": true,
"**/*.pytype": true,
"**/.vscode-server": true,
},
"files.watcherExclude": {
// git
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/.tox/*/**": true,
"**/.eggs/*/**": true,
"**/*.egg-info/*/**": true,
"**/__pycache__/*/**": true,
"**/.cache/*/**": true,
"**/.mypy_cache/*/**": true,
"**/.pytest_cache/*/**": true,
"**/logs/*/**": true,
// python
"**/.tox": true,
"**/.nox": true,
"**/.eggs": true,
"**/*.egg-info": true,
"**/__pycache__": true,
"**/__pypackages__": true,
"**/.cache": true,
"**/.mypy_cache": true,
"**/.pytest_cache": true,
"**/.ruff_cache": true,
"**/.ipynb_checkpoints": true,
"**/*.pyc": true,
"**/*.egg": true,
"**/*.venv": true,
"**/*.pyenv": true,
"**/*.pytype": true,
"**/_build": true,
"**/build": true,
"**/dist": true,
"**/site-packages": true,
// others
"**/logs": true,
"**/*.log": true,
"**/.vscode-server/*/**": true,
"**/.vscode-server": true,
"**/example.*": true,
},
"search.exclude": {
// git
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/.tox/*/**": true,
"**/.eggs/*/**": true,
"**/*.egg-info/*/**": true,
"**/__pycache__/*/**": true,
"**/.cache/*/**": true,
"**/.mypy_cache/*/**": true,
"**/.pytest_cache/*/**": true,
"**/logs/*/**": true,
// python
"**/.tox": true,
"**/.nox": true,
"**/.eggs": true,
"**/*.egg-info": true,
"**/__pycache__": true,
"**/__pypackages__": true,
"**/.cache": true,
"**/.mypy_cache": true,
"**/.pytest_cache": true,
"**/.ruff_cache": true,
"**/.ipynb_checkpoints": true,
"**/*.pyc": true,
"**/*.egg": true,
"**/*.venv": true,
"**/*.pyenv": true,
"**/*.pytype": true,
"**/_build": true,
"**/build": true,
"**/dist": true,
"**/site-packages": true,
// others
"**/*.log": true,
"**/.vscode-server/*/**": true,
"**/logs": true,
"**/.vscode-server": true,
"**/example.*": true,
},
//
//-- Python language settings ------------------------------------------------------
//
"[python]": {
// SETTINGS OF FOR PYTHON
// Editor settings for python files
"editor.tabSize": 4,
"editor.wordWrapColumn": 83,
"files.eol": "\n",
"files.encoding": "utf8",
// "editor.trimAutoWhitespace": true, // disabled for now
// "files.trimFinalNewlines": true, // for reducing git changes due to whitespaces
// "files.trimTrailingWhitespace": true,
// SETTINGS EXCLUSIVE TO PYTHON
"editor.defaultFormatter": "charliermarsh.ruff",
// "editor.defaultFormatter": "ms-python.black-formatter",
//-- Settings for keeping source code compatibility
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.insertSpaces": true,
"files.insertFinalNewline": true,
//-- Settings to reduce git changes due to whitespaces up source code (disabled for now)
// "editor.trimAutoWhitespace": true,
// "files.trimFinalNewlines": true,
// "files.trimTrailingWhitespace": true,
},
"python.formatting.provider": "black",
"python.autoComplete.extraPaths": [
"${workspaceFolder}/petl/",
"${workspaceFolder}/petl/io/",
Expand All @@ -76,12 +124,15 @@
"${workspaceFolder}/petl/test/",
"${workspaceFolder}/petl/test/io",
],
"python.linting.enabled": true,
"python.linting.maxNumberOfProblems": 12,
"python.linting.ignorePatterns": [
//
//-- Python analysis/tools settings ------------------------------------------------
//
"python.analysis.logLevel": "Warning",
"pylint.ignorePatterns": [
".vscode/*.py",
".git",
".tox",
".nox",
".venv",
".eggs",
".egg-info",
Expand All @@ -91,17 +142,15 @@
"__pycache__",
"_build",
"*.pyc",
".vscode",
".vscode-server",
],
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"pylint.args": [
"--max-line-length=83",
"--reports=y",
"--disable=import-error,invalid-name,bad-continuation,import-outside-toplevel,missing-module-docstring,missing-function-docstring,trailing-whitespace,line-too-long,bad-whitespace"
],
"python.analysis.logLevel": "Warning",
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": [
"flake8.args": [
"--max-line-length",
"83",
"--max-complexity",
Expand All @@ -111,8 +160,7 @@
"--exclude",
".git,.tox,.venv,.eggs,.egg-info,.cache,.mypy_cache,.pytest_cache,.vscode,__pycache__,_build,*.pyc,.vscode-server"
],
"python.linting.mypyEnabled": false,
"python.linting.mypyArgs": [
"mypy-type-checker.args": [
"--allow-untyped-defs",
"--allow-untyped-calls",
"--allow-untyped-globals",
Expand All @@ -129,5 +177,9 @@
"${workspaceFolder}/petl/util/",
"${workspaceFolder}/petl/test/",
"${workspaceFolder}/petl/test/io"
],
"bandit.args": [
"--configfile",
"${workspaceFolder}/pyproject.toml"
]
}
14 changes: 7 additions & 7 deletions examples/notes/issue_219.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# <codecell>

%memit print tbl_dummy_data.nrows()
print tbl_dummy_data.nrows()

# <headingcell level=2>

Expand All @@ -43,17 +43,17 @@

# <codecell>

%memit -r1 tbl_dummy_data.progress(10000).todb(psql_connection, 'issue_219')
tbl_dummy_data.progress(10000).todb(psql_connection, 'issue_219')

# <codecell>

# memory usage using default cursor
%memit print etl.fromdb(psql_connection, 'select * from issue_219 order by foo').look(2)
print etl.fromdb(psql_connection, 'select * from issue_219 order by foo').look(2)

# <codecell>

# memory usage using server-side cursor
%memit print etl.fromdb(lambda: psql_connection.cursor(name='server-side'), 'select * from issue_219 order by foo').look(2)
print etl.fromdb(lambda: psql_connection.cursor(name='server-side'), 'select * from issue_219 order by foo').look(2)
Dismissed Show dismissed Hide dismissed

# <headingcell level=2>

Expand All @@ -72,15 +72,15 @@

# <codecell>

%memit -r1 tbl_dummy_data.progress(10000).todb(mysql_connection, 'issue_219')
tbl_dummy_data.progress(10000).todb(mysql_connection, 'issue_219')

# <codecell>

# memory usage with default cursor
%memit print etl.fromdb(mysql_connection, 'select * from issue_219 order by foo').look(2)
print etl.fromdb(mysql_connection, 'select * from issue_219 order by foo').look(2)

# <codecell>

# memory usage with server-side cursor
%memit print etl.fromdb(lambda: mysql_connection.cursor(MySQLdb.cursors.SSCursor), 'select * from issue_219 order by foo').look(2)
print etl.fromdb(lambda: mysql_connection.cursor(MySQLdb.cursors.SSCursor), 'select * from issue_219 order by foo').look(2)
Dismissed Show dismissed Hide dismissed

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
[build-system]
requires = ["setuptools", "setuptools-scm", "wheel"]

[tool.bandit]
exclude_dirs = ["bin", "docs"]

[tool.bandit.assert_used]
skips = ["*/*_test.py", "*/test_*.py"]
17 changes: 17 additions & 0 deletions requirements-linting.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Used as main formatter/linter:

ruff >= 0.3

# Used in Github:

pylint >= 3.0.0
flake8 >= 7.0.0
black >= 24.0.0
bandit[toml,sarif] >= 1.7.0

## Suggestions:

# pre-commit

#? Obs: Should work with python >= 3.8

Loading