Skip to content

Commit bd7c848

Browse files
committed
added pre-commit, first pass of lint
1 parent c312af0 commit bd7c848

38 files changed

+608
-362
lines changed

.devcontainer/Dockerfile

-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ FROM mcr.microsoft.com/devcontainers/python:0-3.10
22

33
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
44

5-
# Uninstall pre-installed formatting and linting tools
6-
# They would conflict with our pinned versions
7-
RUN pipx uninstall black
8-
RUN pipx uninstall flake8
9-
RUN pipx uninstall pydocstyle
10-
RUN pipx uninstall pycodestyle
11-
RUN pipx uninstall mypy
12-
RUN pipx uninstall pylint
13-
145
RUN \
156
apt-get update \
167
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \

.devcontainer/devcontainer.json

+38-38
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
{
2-
"name": "iCloudPy Dev",
3-
"context": "..",
4-
"dockerFile": "Dockerfile",
5-
"containerEnv": { "DEVCONTAINER": "1" },
6-
"extensions": [
7-
"ms-python.vscode-pylance",
8-
"visualstudioexptteam.vscodeintellicode",
9-
"redhat.vscode-yaml",
10-
"esbenp.prettier-vscode",
11-
"GitHub.vscode-pull-request-github"
12-
],
13-
// Please keep this file in sync with settings in home-assistant/.vscode/settings.default.json
14-
"settings": {
15-
"python.linting.enabled": true,
16-
"python.linting.pylintEnabled": true,
17-
"python.formatting.blackPath": "/usr/local/bin/black",
18-
"python.formatting.provider": "black",
19-
"python.testing.pytestArgs": ["--no-cov"],
20-
"editor.formatOnPaste": false,
21-
"editor.formatOnSave": true,
22-
"editor.formatOnType": true,
23-
"files.trimTrailingWhitespace": true,
24-
"terminal.integrated.profiles.linux": {
25-
"zsh": {
26-
"path": "/usr/bin/zsh"
27-
}
28-
},
29-
"terminal.integrated.defaultProfile.linux": "zsh",
30-
"yaml.customTags": [
31-
"!input scalar",
32-
"!secret scalar",
33-
"!include_dir_named scalar",
34-
"!include_dir_list scalar",
35-
"!include_dir_merge_list scalar",
36-
"!include_dir_merge_named scalar"
37-
]
38-
}
39-
}
2+
"name": "iCloudPy Dev",
3+
"context": "..",
4+
"dockerFile": "Dockerfile",
5+
"containerEnv": { "DEVCONTAINER": "1" },
6+
"extensions": [
7+
"ms-python.vscode-pylance",
8+
"visualstudioexptteam.vscodeintellicode",
9+
"redhat.vscode-yaml",
10+
"esbenp.prettier-vscode",
11+
"GitHub.vscode-pull-request-github"
12+
],
13+
// Please keep this file in sync with settings in home-assistant/.vscode/settings.default.json
14+
"settings": {
15+
"python.linting.enabled": true,
16+
"python.linting.pylintEnabled": true,
17+
"python.formatting.blackPath": "/usr/local/bin/black",
18+
"python.formatting.provider": "black",
19+
"python.testing.pytestArgs": ["--no-cov"],
20+
"editor.formatOnPaste": false,
21+
"editor.formatOnSave": true,
22+
"editor.formatOnType": true,
23+
"files.trimTrailingWhitespace": true,
24+
"terminal.integrated.profiles.linux": {
25+
"zsh": {
26+
"path": "/usr/bin/zsh"
27+
}
28+
},
29+
"terminal.integrated.defaultProfile.linux": "zsh",
30+
"yaml.customTags": [
31+
"!input scalar",
32+
"!secret scalar",
33+
"!include_dir_named scalar",
34+
"!include_dir_list scalar",
35+
"!include_dir_merge_list scalar",
36+
"!include_dir_merge_named scalar"
37+
]
38+
}
39+
}

.flake8

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 120

.github/ISSUE_TEMPLATE/bug_report.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ about: Create a report to help us improve
44
title: "[BUG]"
55
labels: bug
66
assignees: mandarons
7-
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Do this '...'
1616
2. See error
1717

@@ -25,4 +25,4 @@ If applicable, add screenshots to help explain your problem.
2525
If applicable, please share the configuration details
2626

2727
**Additional context**
28-
Add any other context about the problem here.
28+
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/feature_request.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ about: Suggest an idea for this project
44
title: "[FEATURE]"
55
labels: enhancement
66
assignees: mandarons
7-
87
---
98

109
**Use case**
@@ -17,4 +16,4 @@ A clear and concise description of what you want to happen.
1716
A clear and concise description of any alternative solutions or features you've considered.
1817

1918
**Additional context**
20-
Add any other context or screenshots about the feature request here.
19+
Add any other context or screenshots about the feature request here.

.pre-commit-config.yaml

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
repos:
2+
- repo: https://github.com/asottile/pyupgrade
3+
rev: v3.3.1
4+
hooks:
5+
- id: pyupgrade
6+
args: [--py39-plus]
7+
- repo: https://github.com/PyCQA/autoflake
8+
rev: v2.0.0
9+
hooks:
10+
- id: autoflake
11+
args:
12+
- --in-place
13+
- --remove-all-unused-imports
14+
- repo: https://github.com/psf/black
15+
rev: 22.12.0
16+
hooks:
17+
- id: black
18+
args:
19+
- --quiet
20+
files: ^((src|tests)/.+)?[^/]+\.py$
21+
- repo: https://github.com/codespell-project/codespell
22+
rev: v2.2.2
23+
hooks:
24+
- id: codespell
25+
args:
26+
- --skip="./.*,*.csv,*.json"
27+
- --quiet-level=2
28+
exclude: ^tests/data/
29+
- repo: https://github.com/PyCQA/flake8
30+
rev: 6.0.0
31+
hooks:
32+
- id: flake8
33+
additional_dependencies:
34+
- pycodestyle==2.10.0
35+
- pyflakes==3.0.1
36+
- flake8-docstrings==1.6.0
37+
- pydocstyle==6.1.1
38+
- flake8-comprehensions==3.10.1
39+
- flake8-noqa==1.3.0
40+
- mccabe==0.7.0
41+
files: ^(src|tests)/.+\.py$
42+
- repo: https://github.com/PyCQA/bandit
43+
rev: 1.7.4
44+
hooks:
45+
- id: bandit
46+
args:
47+
- --quiet
48+
- --format=custom
49+
- --configfile=tests/bandit.yaml
50+
files: ^(src|tests)/.+\.py$
51+
- repo: https://github.com/PyCQA/isort
52+
rev: 5.11.4
53+
hooks:
54+
- id: isort
55+
args:
56+
- --profile=black
57+
- repo: https://github.com/pre-commit/pre-commit-hooks
58+
rev: v3.2.0
59+
hooks:
60+
- id: check-executables-have-shebangs
61+
stages: [manual]
62+
- id: check-json
63+
exclude: (.vscode|.devcontainer)
64+
- id: no-commit-to-branch
65+
args:
66+
- --branch=dev
67+
- --branch=main
68+
- --branch=rc
69+
- repo: https://github.com/adrienverge/yamllint.git
70+
rev: v1.28.0
71+
hooks:
72+
- id: yamllint
73+
- repo: https://github.com/pre-commit/mirrors-prettier
74+
rev: v2.7.1
75+
hooks:
76+
- id: prettier
77+
# - repo: https://github.com/cdce8p/python-typing-update
78+
# rev: v0.5.0
79+
# hooks:
80+
# # Run `python-typing-update` hook manually from time to time
81+
# # to update python typing syntax.
82+
# # Will require manual work, before submitting changes!
83+
# # pre-commit run --hook-stage manual python-typing-update --all-files
84+
# - id: python-typing-update
85+
# stages: [manual]
86+
# args:
87+
# - --py39-plus
88+
# - --force
89+
# - --keep-updates
90+
# files: ^(icloudpy|tests)/.+\.py$
91+
- repo: local
92+
hooks:
93+
# Run mypy through our wrapper script in order to get the possible
94+
# pyenv and/or virtualenv activated; it may not have been e.g. if
95+
# committing from a GUI tool that was not launched from an activated
96+
# shell.
97+
# - id: mypy
98+
# name: mypy
99+
# entry: run-in-env.sh mypy
100+
# language: script
101+
# types: [python]
102+
# require_serial: true
103+
# files: ^(icloudpy|pylint)/.+\.py$
104+
- id: pylint
105+
name: pylint
106+
entry: run-in-env.sh pylint -j 0
107+
language: script
108+
types: [python]
109+
files: ^icloudpy/.+\.py$

.yamllint

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
ignore: |
2+
azure-*.yml
3+
rules:
4+
braces:
5+
level: error
6+
min-spaces-inside: 0
7+
max-spaces-inside: 1
8+
min-spaces-inside-empty: -1
9+
max-spaces-inside-empty: -1
10+
brackets:
11+
level: error
12+
min-spaces-inside: 0
13+
max-spaces-inside: 0
14+
min-spaces-inside-empty: -1
15+
max-spaces-inside-empty: -1
16+
colons:
17+
level: error
18+
max-spaces-before: 0
19+
max-spaces-after: 1
20+
commas:
21+
level: error
22+
max-spaces-before: 0
23+
min-spaces-after: 1
24+
max-spaces-after: 1
25+
comments:
26+
level: error
27+
require-starting-space: true
28+
min-spaces-from-content: 1
29+
comments-indentation:
30+
level: error
31+
document-end:
32+
level: error
33+
present: false
34+
document-start:
35+
level: error
36+
present: false
37+
empty-lines:
38+
level: error
39+
max: 1
40+
max-start: 0
41+
max-end: 1
42+
hyphens:
43+
level: error
44+
max-spaces-after: 1
45+
indentation:
46+
level: error
47+
spaces: 2
48+
indent-sequences: true
49+
check-multi-line-strings: false
50+
key-duplicates:
51+
level: error
52+
line-length: disable
53+
new-line-at-end-of-file:
54+
level: error
55+
new-lines:
56+
level: error
57+
type: unix
58+
trailing-spaces:
59+
level: error
60+
truthy:
61+
level: error
62+
allowed-values:
63+
- "on"
64+
- "true"
65+
- "false"

0 commit comments

Comments
 (0)