Skip to content

Commit

Permalink
Merge pull request #8 from blackary/linting
Browse files Browse the repository at this point in the history
Add linting
  • Loading branch information
blackary authored Sep 8, 2022
2 parents 96cd2e5 + 3ce09b2 commit 7071cee
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 3 deletions.
20 changes: 20 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[flake8]
max-line-length = 88
select =
E # pep8 errors
F # pyflakes errors
W # pep8 warnings
B # flake8-bugbear warnings
ignore =
E501 # "Line lengths are recommended to be no greater than 79 characters"
E203 # "Whitespace before ':'": conflicts with black
W503 # "line break before binary operator": conflicts with black
exclude =
.git
.vscode
.pytest_cache
.mypy_cache
.venv
.env
.direnv
per-file-ignores =
13 changes: 13 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: linting

on:
pull_request:
push:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repos:
- repo: https://gitlab.com/pycqa/flake8
rev: "4.0.1"
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- repo: https://github.com/psf/black
rev: "22.3.0"
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: "5.10.1"
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v0.942"
hooks:
- id: mypy
args:
- --ignore-missing-imports
- --follow-imports=silent
additional_dependencies:
- types-all
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0 # Use the ref you want to point at
hooks:
- id: trailing-whitespace
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool.isort]
profile = "black"
line_length = 88
skip = ["./.venv", "./direnv", ".env"]

[tool.black]
exclude = '''
(
/(
\.vscode
| \.git
| \.pytest_cache
| \.mypy_cache
| \.venv
| \.env
| \.direnv
)/
)
'''
include = '\.pyi?$'
line-length = 88

[tool.mypy]
files = [
"**/*.py",
]
follow_imports = "silent"
ignore_missing_imports = true
scripts_are_modules = true
python_version = 3.9
9 changes: 7 additions & 2 deletions src/st_keyup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def st_keyup(
label: str,
value: str = "",
key: Optional[str] = None,
debounce: int = 0,
debounce: Optional[int] = None,
on_change: Optional[Callable] = None,
args: Optional[Tuple[Any, ...]] = None,
kwargs: Optional[Dict[str, Any]] = None,
Expand Down Expand Up @@ -93,7 +93,12 @@ def on_change2(*args, **kwargs):
st.write(value)

"## Keyup input with args"
value = st_keyup("Enter a fourth value...", on_change=on_change2, args=("Hello", "World"), kwargs={"foo": "bar"})
value = st_keyup(
"Enter a fourth value...",
on_change=on_change2,
args=("Hello", "World"),
kwargs={"foo": "bar"},
)
st.write(value)

"## Standard text input for comparison"
Expand Down
2 changes: 1 addition & 1 deletion src/st_keyup/frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function onRender(event) {
input.value = value
}

if (debounce_time > 0) {
if (debounce_time > 0) { // is false if debounce_time is 0 or undefined
input.onkeyup = debounce(onKeyUp, debounce_time)
}
else {
Expand Down

0 comments on commit 7071cee

Please sign in to comment.