Skip to content

Commit aa811c4

Browse files
Update precommit hooks (#27)
* Update precommit hooks * Add more precommit hooks
1 parent cf85a85 commit aa811c4

7 files changed

Lines changed: 65 additions & 42 deletions

File tree

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
# for error classes selected below.
1212

1313
[flake8]
14-
max-line-length = 80
14+
max-line-length = 88
1515
select = C,E,F,W,B,B950
1616
ignore = E501, W503

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release
33
on:
44
push:
55
tags:
6-
- '*.*'
6+
- "*.*"
77

88
jobs:
99
release:
@@ -14,8 +14,8 @@ jobs:
1414
- name: Setup Python 3.10
1515
uses: actions/setup-python@v4
1616
with:
17-
python-version: '3.10'
18-
architecture: 'x64'
17+
python-version: "3.10"
18+
architecture: "x64"
1919

2020
- name: Install flit
2121
run: pip install flit

.github/workflows/test.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ jobs:
1111
python-version: ["3.10"]
1212

1313
steps:
14-
- uses: actions/checkout@v3
15-
- name: Set up Python ${{ matrix.python-version }}
16-
uses: actions/setup-python@v4
17-
with:
18-
python-version: ${{ matrix.python-version }}
14+
- uses: actions/checkout@v3
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: ${{ matrix.python-version }}
1919

20-
- uses: actions/cache@v3
21-
with:
22-
path: ~/.cache/pip
23-
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
24-
restore-keys: |
25-
${{ runner.os }}-pip-
20+
- uses: actions/cache@v3
21+
with:
22+
path: ~/.cache/pip
23+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
24+
restore-keys: |
25+
${{ runner.os }}-pip-
2626
27-
- name: Install dependencies
28-
run: |
29-
python -m pip install --upgrade pip
30-
pip install flit
31-
flit install
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install flit
31+
flit install
3232
33-
- name: Lint
34-
run: pre-commit run --all-files --show-diff-on-failure --color always
33+
- name: Lint
34+
run: pre-commit run --all-files --show-diff-on-failure --color always
3535

36-
- name: Test
37-
run: |
38-
pytest
36+
- name: Test
37+
run: |
38+
pytest

.pre-commit-config.yaml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,44 @@
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.1.0
6+
rev: v4.3.0
77
hooks:
8-
- id: check-yaml
9-
- id: end-of-file-fixer
108
- id: trailing-whitespace
9+
- id: end-of-file-fixer
10+
- id: debug-statements
11+
- id: check-ast
12+
- id: mixed-line-ending
13+
- id: check-yaml
14+
args: [--allow-multiple-documents]
15+
- id: check-json
16+
- id: check-toml
17+
- id: check-added-large-files
18+
1119
- repo: https://github.com/psf/black
12-
rev: 22.3.0
20+
rev: 22.6.0
1321
hooks:
1422
- id: black
23+
1524
- repo: https://gitlab.com/pycqa/flake8
16-
rev: 3.8.4
25+
rev: 3.9.2
1726
hooks:
1827
- id: flake8
1928
pass_filenames: true
29+
2030
- repo: https://github.com/pycqa/isort
2131
rev: 5.10.1
2232
hooks:
2333
- id: isort
34+
35+
- repo: https://github.com/asottile/pyupgrade
36+
rev: v2.37.3
37+
hooks:
38+
- id: pyupgrade
39+
args: [--py38-plus]
40+
41+
- repo: https://github.com/pre-commit/mirrors-prettier
42+
rev: v2.7.1
43+
hooks:
44+
- id: prettier
45+
files: \.(html|md|yml|yaml)
46+
args: [--prose-wrap=preserve]

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# YAML to iCalendar (ics)
44

55
| WARNING: this project is still in beta. Beware of breaking changes! |
6-
|---------------------------------------------------------------------|
6+
| ------------------------------------------------------------------- |
77

88
Convert YAML files to .ics files which can be imported into other
99
calendar applications.
1010

1111
Features include:
12+
1213
- Converting single .yaml files, or combining multiple into one .ics
1314
file.
1415
- ics fields: name, summary, description, location, timezone, repeat
@@ -47,11 +48,11 @@ python yaml2ics.py example/test_calendar.yaml example/another_calendar.yaml
4748
## Syntax
4849

4950
Please see `example/test_calendar.yaml` for a full demo including
50-
explanations. Below is a minimal template that shows the basic idea:
51+
explanations. Below is a minimal template that shows the basic idea:
5152

5253
```yaml
5354
name: Calendar Name
54-
timezone: Europe/Helsinki # default timezone for events, optional
55+
timezone: Europe/Helsinki # default timezone for events, optional
5556

5657
events:
5758
- summary: The event title
@@ -84,8 +85,7 @@ pytest
8485

8586
[black](https://github.com/psf/black) and other linters are used to auto-format
8687
files (and enforced by CI). To install the git hooks, use `pre-commit install`.
87-
To run the tests/auto-formatting manually, use `pre-commit run
88-
--all-files`.
88+
To run the tests/auto-formatting manually, use `pre-commit run --all-files`.
8989

9090
Releases are automatically pushed on PyPi by the CI when pushing a tag
9191
following `*.*`.

example/test_calendar.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ timezone: America/Los_Angeles
77

88
events:
99
- summary: Event of the Century
10-
begin: 2021-09-21 15:00:00 # uses default timezone above
10+
begin: 2021-09-21 15:00:00 # uses default timezone above
1111
duration:
1212
minutes: 30
1313
description: |
@@ -16,22 +16,22 @@ events:
1616
Office 224, Monolith Bldg, Office Block C
1717
1818
- summary: 15-minute meeting with timezone
19-
timezone: America/New_York # symbolic timezone offset
19+
timezone: America/New_York # symbolic timezone offset
2020
begin: 2021-09-23 15:00:00
2121
end: 2021-09-23 15:30:00
2222

2323
- summary: Half-an-hour meeting
24-
begin: 2021-09-23 15:00:00 -07:00 # explicit timezone offset
25-
end: 2021-09-23 15:30:00 -07:00 # explicit timezone offset
24+
begin: 2021-09-23 15:00:00 -07:00 # explicit timezone offset
25+
end: 2021-09-23 15:30:00 -07:00 # explicit timezone offset
2626

2727
- summary: Recurring event
2828
begin: 2022-02-21 15:00:00
29-
duration: {minutes: 60}
29+
duration: { minutes: 60 }
3030
repeat:
3131
interval:
3232
# seconds, minutes, hours, days, weeks, months, years
3333
weeks: 1
34-
until: 2022-12-31 # required
34+
until: 2022-12-31 # required
3535

3636
# All-day event
3737
- summary: Earth Day

yaml2ics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def files_to_events(files: list) -> (ics.Calendar, str):
112112
if hasattr(f, "read"):
113113
calendar_yaml = yaml.load(f.read(), Loader=yaml.FullLoader)
114114
else:
115-
calendar_yaml = yaml.load(open(f, "r"), Loader=yaml.FullLoader)
115+
calendar_yaml = yaml.load(open(f), Loader=yaml.FullLoader)
116116
tz = calendar_yaml.get("timezone", None)
117117
if tz is not None:
118118
tz = gettz(tz)

0 commit comments

Comments
 (0)