From 0c1bf1c6dd939d1621bb012733d868dc1cf3e9b6 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 3 Oct 2023 08:53:27 -0500 Subject: [PATCH 1/5] ietf no longer serves leapseconddata, use alternate sources --- leapseconddata/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/leapseconddata/__init__.py b/leapseconddata/__init__.py index 4101b08..435a6c1 100755 --- a/leapseconddata/__init__.py +++ b/leapseconddata/__init__.py @@ -213,7 +213,8 @@ def from_standard_source( for location in [ # pragma no branch "file:///usr/share/zoneinfo/leap-seconds.list", # Debian Linux "file:///var/db/ntpd.leap-seconds.list", # FreeBSD - "https://www.ietf.org/timezones/data/leap-seconds.list", + "https://raw.githubusercontent.com/eggert/tz/main/leap-seconds.list", + "https://www.meinberg.de/download/ntp/leap-seconds.list", ]: logging.debug("Trying leap second data from %s", location) try: From 0f62a551540789a258e6736b49e7ab7466c763b0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 3 Oct 2023 08:56:17 -0500 Subject: [PATCH 2/5] test across oses --- .github/workflows/test.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d1ff4f..8121661 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,22 +33,25 @@ jobs: strategy: matrix: python-version: - - '3.7' - '3.8' - '3.9' - '3.10' - - 'pypy-3.7' + - '3.11' + - '3.12.0-alpha.0 - 3.12' + - 'pypy-3.9' + os-version: + - 'ubuntu-latest' + include: + - os-version: 'macos-latest' + python-version: '3.x' + - os-version: 'windows-latest' + python-version: '3.x' env: PYTHON: ${{ matrix.python-version }} - runs-on: ubuntu-latest + runs-on: ${{ matrix.os-version }} steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - uses: actions/checkout@v2.2.0 - name: Set up Python From f280d36d26361b9affad7464e98de792ca68d799 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 3 Oct 2023 08:57:23 -0500 Subject: [PATCH 3/5] Add pre-commit --- .pre-commit-config.yaml | 49 +++++++++++++++++++------------------- leapseconddata/__init__.py | 3 ++- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 790bd09..c4770f8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,34 +2,33 @@ # # SPDX-License-Identifier: Unlicense +default_language_version: + python: python3 + repos: -- repo: https://github.com/python/black - rev: 22.8.0 - hooks: - - id: black -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 - hooks: - - id: check-yaml - - id: end-of-file-fixer - exclude: tests - - id: trailing-whitespace - exclude: tests -- repo: https://github.com/fsfe/reuse-tool - rev: v1.0.0 - hooks: - - id: reuse -- repo: local - hooks: - - id: pylint - name: pylint - entry: pylint - language: python - types: [python] - additional_dependencies: [beautifulsoup4, "pylint==2.15.3", requests, adafruit-circuitpython-datetime, click, python-dateutil] +- repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort name: isort (python) args: ['--profile', 'black'] +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + exclude: tests + - id: trailing-whitespace + exclude: tests +- repo: https://github.com/fsfe/reuse-tool + rev: v2.1.0 + hooks: + - id: reuse +- repo: https://github.com/pycqa/pylint + rev: v2.17.1 + hooks: + - id: pylint diff --git a/leapseconddata/__init__.py b/leapseconddata/__init__.py index 435a6c1..fc79cdb 100755 --- a/leapseconddata/__init__.py +++ b/leapseconddata/__init__.py @@ -146,7 +146,8 @@ def to_tai( :param when: Moment in time to convert. If naive, it is assumed to be in UTC. :param check_validity: Check whether the database is valid for the given moment - Naive timestamps are assumed to be UTC. A TAI timestamp is returned unchanged.""" + Naive timestamps are assumed to be UTC. A TAI timestamp is returned unchanged. + """ if datetime_is_tai(when): return when when = self._utc_datetime(when) From b5e7f3eff61cdb7eca356b427f57b6a126d4b6ee Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 3 Oct 2023 09:01:37 -0500 Subject: [PATCH 4/5] tune when mypy is run --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8121661..b160ef8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,10 +52,10 @@ jobs: runs-on: ${{ matrix.os-version }} steps: - - uses: actions/checkout@v2.2.0 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -63,7 +63,7 @@ jobs: run: python -mpip install -r requirements-dev.txt - name: Check stubs - if: (! startsWith(matrix.python-version, 'pypy-')) + if: (startsWith(matrix.python-version, '3.12') && startswith(matrix.os-version, 'ubuntu-')) run: mypy --strict *.py - name: Test From 7724600eb8fc66b5d8f437c89696e5699e3a7c22 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 3 Oct 2023 09:06:48 -0500 Subject: [PATCH 5/5] update pre-commit workflow versions --- .github/workflows/test.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b160ef8..600e494 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -78,12 +78,6 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 - - name: set PY - run: echo >>$GITHUB_ENV PY="$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" - - uses: actions/cache@v1 - with: - path: ~/.cache/pre-commit - key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} - - uses: pre-commit/action@v1.1.0 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + - uses: pre-commit/action@v3.0.0