From 8fd7ccf9a8c607cdf7b0333d6fea2ff87e3176e6 Mon Sep 17 00:00:00 2001 From: Jarrod Millman Date: Tue, 9 Aug 2022 20:44:31 -0700 Subject: [PATCH 1/2] Update precommit hooks --- .pre-commit-config.yaml | 27 ++++++++++++++++++++++----- yaml2ics.py | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 29ef555..4641cf4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,22 +2,39 @@ # pre-commit install repos: + - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.3.0 hooks: - - id: check-yaml - - id: end-of-file-fixer - id: trailing-whitespace + - id: end-of-file-fixer + - id: debug-statements + - id: check-ast + - id: mixed-line-ending + - id: check-yaml + args: [--allow-multiple-documents] + - id: check-json + - id: check-toml + - id: check-added-large-files + - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.6.0 hooks: - id: black + - repo: https://gitlab.com/pycqa/flake8 - rev: 3.8.4 + rev: 3.9.2 hooks: - id: flake8 pass_filenames: true + - repo: https://github.com/pycqa/isort rev: 5.10.1 hooks: - id: isort + + - repo: https://github.com/asottile/pyupgrade + rev: v2.37.3 + hooks: + - id: pyupgrade + args: [--py38-plus] diff --git a/yaml2ics.py b/yaml2ics.py index 272f420..f829cb2 100644 --- a/yaml2ics.py +++ b/yaml2ics.py @@ -112,7 +112,7 @@ def files_to_events(files: list) -> (ics.Calendar, str): if hasattr(f, "read"): calendar_yaml = yaml.load(f.read(), Loader=yaml.FullLoader) else: - calendar_yaml = yaml.load(open(f, "r"), Loader=yaml.FullLoader) + calendar_yaml = yaml.load(open(f), Loader=yaml.FullLoader) tz = calendar_yaml.get("timezone", None) if tz is not None: tz = gettz(tz) From e50916672633fc2b2f4327012ffa563764db8ddb Mon Sep 17 00:00:00 2001 From: Jarrod Millman Date: Tue, 9 Aug 2022 20:51:15 -0700 Subject: [PATCH 2/2] Add more precommit hooks --- .flake8 | 2 +- .github/workflows/release.yml | 6 ++--- .github/workflows/test.yml | 42 +++++++++++++++++------------------ .pre-commit-config.yaml | 8 ++++++- README.md | 10 ++++----- example/test_calendar.yaml | 12 +++++----- 6 files changed, 43 insertions(+), 37 deletions(-) diff --git a/.flake8 b/.flake8 index 217a665..4994bd6 100644 --- a/.flake8 +++ b/.flake8 @@ -11,6 +11,6 @@ # for error classes selected below. [flake8] -max-line-length = 80 +max-line-length = 88 select = C,E,F,W,B,B950 ignore = E501, W503 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d30e72..258ce4f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: tags: - - '*.*' + - "*.*" jobs: release: @@ -14,8 +14,8 @@ jobs: - name: Setup Python 3.10 uses: actions/setup-python@v4 with: - python-version: '3.10' - architecture: 'x64' + python-version: "3.10" + architecture: "x64" - name: Install flit run: pip install flit diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6dcad20..4dbd2d8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,28 +11,28 @@ jobs: python-version: ["3.10"] steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} - restore-keys: | - ${{ runner.os }}-pip- + - uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }} + restore-keys: | + ${{ runner.os }}-pip- - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flit - flit install + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flit + flit install - - name: Lint - run: pre-commit run --all-files --show-diff-on-failure --color always + - name: Lint + run: pre-commit run --all-files --show-diff-on-failure --color always - - name: Test - run: | - pytest + - name: Test + run: | + pytest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4641cf4..08aafab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,6 @@ # pre-commit install repos: - - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: @@ -38,3 +37,10 @@ repos: hooks: - id: pyupgrade args: [--py38-plus] + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.7.1 + hooks: + - id: prettier + files: \.(html|md|yml|yaml) + args: [--prose-wrap=preserve] diff --git a/README.md b/README.md index 5e81649..0a56f7a 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,13 @@ # YAML to iCalendar (ics) | WARNING: this project is still in beta. Beware of breaking changes! | -|---------------------------------------------------------------------| +| ------------------------------------------------------------------- | Convert YAML files to .ics files which can be imported into other calendar applications. Features include: + - Converting single .yaml files, or combining multiple into one .ics file. - ics fields: name, summary, description, location, timezone, repeat @@ -47,11 +48,11 @@ python yaml2ics.py example/test_calendar.yaml example/another_calendar.yaml ## Syntax Please see `example/test_calendar.yaml` for a full demo including -explanations. Below is a minimal template that shows the basic idea: +explanations. Below is a minimal template that shows the basic idea: ```yaml name: Calendar Name -timezone: Europe/Helsinki # default timezone for events, optional +timezone: Europe/Helsinki # default timezone for events, optional events: - summary: The event title @@ -84,8 +85,7 @@ pytest [black](https://github.com/psf/black) and other linters are used to auto-format files (and enforced by CI). To install the git hooks, use `pre-commit install`. -To run the tests/auto-formatting manually, use `pre-commit run ---all-files`. +To run the tests/auto-formatting manually, use `pre-commit run --all-files`. Releases are automatically pushed on PyPi by the CI when pushing a tag following `*.*`. diff --git a/example/test_calendar.yaml b/example/test_calendar.yaml index ea8d23d..bec6315 100644 --- a/example/test_calendar.yaml +++ b/example/test_calendar.yaml @@ -7,7 +7,7 @@ timezone: America/Los_Angeles events: - summary: Event of the Century - begin: 2021-09-21 15:00:00 # uses default timezone above + begin: 2021-09-21 15:00:00 # uses default timezone above duration: minutes: 30 description: | @@ -16,22 +16,22 @@ events: Office 224, Monolith Bldg, Office Block C - summary: 15-minute meeting with timezone - timezone: America/New_York # symbolic timezone offset + timezone: America/New_York # symbolic timezone offset begin: 2021-09-23 15:00:00 end: 2021-09-23 15:30:00 - summary: Half-an-hour meeting - begin: 2021-09-23 15:00:00 -07:00 # explicit timezone offset - end: 2021-09-23 15:30:00 -07:00 # explicit timezone offset + begin: 2021-09-23 15:00:00 -07:00 # explicit timezone offset + end: 2021-09-23 15:30:00 -07:00 # explicit timezone offset - summary: Recurring event begin: 2022-02-21 15:00:00 - duration: {minutes: 60} + duration: { minutes: 60 } repeat: interval: # seconds, minutes, hours, days, weeks, months, years weeks: 1 - until: 2022-12-31 # required + until: 2022-12-31 # required # All-day event - summary: Earth Day