Skip to content

Commit 9eea231

Browse files
committed
Merge branch 'master' into refresh
2 parents cfa19d4 + 8b55544 commit 9eea231

File tree

7 files changed

+45
-112
lines changed

7 files changed

+45
-112
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515
- name: Get tag
1616
id: tag
1717
run: |
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: macos-latest
3030
strategy:
3131
matrix:
32-
python-version: [3.6, 3.7, 3.8]
32+
python-version: [3.7, 3.8, 3.9, "3.10"]
3333

3434
steps:
3535
- uses: actions/checkout@v2
@@ -43,8 +43,7 @@ jobs:
4343
python-version: ${{ matrix.python-version }}
4444
- name: Install and set up Poetry
4545
run: |
46-
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
47-
python get-poetry.py -y
46+
curl -fsS https://install.python-poetry.org | python - --preview -y
4847
- name: Build distributions
4948
run: |
5049
source $HOME/.poetry/env
@@ -59,7 +58,7 @@ jobs:
5958
runs-on: windows-latest
6059
strategy:
6160
matrix:
62-
python-version: [3.6, 3.7, 3.8]
61+
python-version: [3.7, 3.8, 3.9, "3.10"]
6362

6463
steps:
6564
- uses: actions/checkout@v2
@@ -74,8 +73,7 @@ jobs:
7473
python-version: ${{ matrix.python-version }}
7574
- name: Install and setup Poetry
7675
run: |
77-
Invoke-WebRequest https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py -O get-poetry.py
78-
python get-poetry.py -y
76+
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python - --preview -y
7977
- name: Build distributions
8078
run: |
8179
$env:Path += ";$env:Userprofile\.poetry\bin"
@@ -104,8 +102,7 @@ jobs:
104102
path: dist
105103
- name: Install and set up Poetry
106104
run: |
107-
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py
108-
python get-poetry.py -y
105+
curl -fsS https://install.python-poetry.org | python - --preview -y
109106
- name: Set up cache
110107
uses: actions/cache@v1
111108
with:

.github/workflows/tests.yml

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,83 +13,64 @@ on:
1313
- '**'
1414

1515
jobs:
16-
Linting:
17-
runs-on: ubuntu-latest
18-
19-
steps:
20-
- uses: actions/checkout@v2
21-
- name: Set up Python 3.9
22-
uses: actions/setup-python@v1
23-
with:
24-
python-version: 3.9
25-
- name: Linting
26-
run: |
27-
pip install pre-commit
28-
pre-commit run --all-files
29-
3016
Tests:
31-
needs: Linting
3217
name: ${{ matrix.os }} / ${{ matrix.python-version }}
3318
runs-on: ${{ matrix.os }}-latest
3419
strategy:
3520
matrix:
3621
os: [Ubuntu, MacOS, Windows]
3722
python-version: [3.7, 3.8, 3.9, "3.10"]
23+
defaults:
24+
run:
25+
shell: bash
26+
3827
steps:
39-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v3
4029

4130
- name: Set up Python ${{ matrix.python-version }}
42-
uses: actions/setup-python@v1
31+
uses: actions/setup-python@v4
4332
with:
4433
python-version: ${{ matrix.python-version }}
4534

4635
- name: Get full Python version
4736
id: full-python-version
48-
shell: bash
49-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
37+
run: |
38+
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
5039
5140
- name: Install poetry
52-
shell: bash
5341
run: |
54-
curl -fsS -o install-poetry.py https://raw.githubusercontent.com/sdispater/poetry/master/install-poetry.py
55-
python install-poetry.py --preview -y
42+
curl -fsS https://install.python-poetry.org | python - --preview -y
5643
5744
- name: Update PATH
5845
if: ${{ matrix.os != 'Windows' }}
59-
shell: bash
6046
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
6147

6248
- name: Update Path for Windows
6349
if: ${{ matrix.os == 'Windows' }}
64-
shell: bash
6550
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
6651

6752
- name: Configure poetry
68-
shell: bash
6953
run: poetry config virtualenvs.in-project true
7054

7155
- name: Set up cache
72-
uses: actions/cache@v2
56+
uses: actions/cache@v3
7357
id: cache
7458
with:
7559
path: .venv
7660
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
7761

7862
- name: Ensure cache is healthy
79-
if: steps.cache.outputs.cache-hit == 'true'
80-
shell: bash
81-
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
63+
# MacOS does not come with `timeout` command out of the box
64+
if: steps.cache.outputs.cache-hit == 'true' && matrix.os != 'MacOS'
65+
run: timeout 10s poetry run pip --version || rm -rf .venv
8266

8367
- name: Install dependencies
84-
shell: bash
85-
run: poetry install --only default --only test -vvv
68+
run: poetry install --only main --only test -vvv
8669

8770
- name: Test Pure Python
88-
shell: bash
8971
run: |
9072
PENDULUM_EXTENSIONS=0 poetry run pytest -q tests
9173
9274
- name: Test
93-
shell: bash
9475
run: |
9576
poetry run pytest -q tests

.pre-commit-config.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
ci:
2+
autofix_prs: false
3+
14
repos:
25
- repo: https://github.com/pre-commit/pre-commit-hooks
36
rev: v4.0.1
@@ -19,6 +22,12 @@ repos:
1922
hooks:
2023
- id: black
2124

25+
- repo: https://github.com/pycqa/isort
26+
rev: 5.10.1
27+
hooks:
28+
- id: isort
29+
args: [--add-import, from __future__ import annotations]
30+
2231
- repo: https://github.com/pycqa/flake8
2332
rev: 4.0.1
2433
hooks:
@@ -42,12 +51,6 @@ repos:
4251
- id: yesqa
4352
additional_dependencies: *flake8_deps
4453

45-
- repo: https://github.com/pycqa/isort
46-
rev: 5.10.1
47-
hooks:
48-
- id: isort
49-
args: [--add-import, from __future__ import annotations]
50-
5154
- repo: https://github.com/asottile/pyupgrade
5255
rev: v2.37.3
5356
hooks:

README.rst

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ Pendulum
1010
.. image:: https://img.shields.io/codecov/c/github/sdispater/pendulum/master.svg
1111
:target: https://codecov.io/gh/sdispater/pendulum/branch/master
1212

13-
.. image:: https://travis-ci.org/sdispater/pendulum.svg
13+
.. image:: https://github.com/sdispater/pendulum/actions/workflows/tests.yml/badge.svg
1414
:alt: Pendulum Build status
15-
:target: https://travis-ci.org/sdispater/pendulum
15+
:target: https://github.com/sdispater/pendulum/actions
16+
1617

1718
Python datetimes made easy.
1819

@@ -36,7 +37,7 @@ Supports Python **2.7** and **3.4+**.
3637
3738
>>> past = pendulum.now().subtract(minutes=2)
3839
>>> past.diff_for_humans()
39-
>>> '2 minutes ago'
40+
'2 minutes ago'
4041
4142
>>> delta = past - last_week
4243
>>> delta.hours
@@ -73,55 +74,6 @@ and by default in ``UTC`` for ease of use.
7374

7475
Pendulum also improves the standard ``timedelta`` class by providing more intuitive methods and properties.
7576

76-
77-
Why not Arrow?
78-
==============
79-
80-
Arrow is the most popular datetime library for Python right now, however its behavior
81-
and API can be erratic and unpredictable. The ``get()`` method can receive pretty much anything
82-
and it will try its best to return something while silently failing to handle some cases:
83-
84-
.. code-block:: python
85-
86-
arrow.get('2016-1-17')
87-
# <Arrow [2016-01-01T00:00:00+00:00]>
88-
89-
pendulum.parse('2016-1-17')
90-
# <Pendulum [2016-01-17T00:00:00+00:00]>
91-
92-
arrow.get('20160413')
93-
# <Arrow [1970-08-22T08:06:53+00:00]>
94-
95-
pendulum.parse('20160413')
96-
# <Pendulum [2016-04-13T00:00:00+00:00]>
97-
98-
arrow.get('2016-W07-5')
99-
# <Arrow [2016-01-01T00:00:00+00:00]>
100-
101-
pendulum.parse('2016-W07-5')
102-
# <Pendulum [2016-02-19T00:00:00+00:00]>
103-
104-
# Working with DST
105-
just_before = arrow.Arrow(2013, 3, 31, 1, 59, 59, 999999, 'Europe/Paris')
106-
just_after = just_before.replace(microseconds=1)
107-
'2013-03-31T02:00:00+02:00'
108-
# Should be 2013-03-31T03:00:00+02:00
109-
110-
(just_after.to('utc') - just_before.to('utc')).total_seconds()
111-
-3599.999999
112-
# Should be 1e-06
113-
114-
just_before = pendulum.datetime(2013, 3, 31, 1, 59, 59, 999999, 'Europe/Paris')
115-
just_after = just_before.add(microseconds=1)
116-
'2013-03-31T03:00:00+02:00'
117-
118-
(just_after.in_timezone('utc') - just_before.in_timezone('utc')).total_seconds()
119-
1e-06
120-
121-
Those are a few examples showing that Arrow cannot always be trusted to have a consistent
122-
behavior with the data you are passing to it.
123-
124-
12577
Limitations
12678
===========
12779

@@ -186,7 +138,7 @@ Getting started
186138
---------------
187139

188140
To work on the Pendulum codebase, you'll want to clone the project locally
189-
and install the required depedendencies via `poetry <https://poetry.eustace.io>`_.
141+
and install the required dependencies via `poetry <https://poetry.eustace.io>`_.
190142

191143
.. code-block:: bash
192144

docs/docs/comparison.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ the `now()` is created in the same timezone as the instance.
6464

6565
>>> born = pendulum.datetime(1987, 4, 23)
6666
>>> not_birthday = pendulum.datetime(2014, 9, 26)
67-
>>> birthday = pendulum.datetime(2014, 2, 23)
67+
>>> birthday = pendulum.datetime(2014, 4, 23)
6868
>>> past_birthday = pendulum.now().subtract(years=50)
6969

7070
>>> born.is_birthday(not_birthday)

docs/docs/period.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ instances that generated it, so that it can give access to more methods and prop
2727
2 # 832 for the duration
2828

2929
# However the days property will still remain the same
30-
# to keep the compatiblity with the timedelta class
30+
# to keep the compatibility with the timedelta class
3131
>>> period.days
3232
5829
3333
```

pendulum/formatting/formatter.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Formatter:
6565
"Mo": None,
6666
"DDDo": None,
6767
"Do": lambda locale: tuple(
68-
fr"\d+{o}" for o in locale.get("custom.ordinal").values()
68+
rf"\d+{o}" for o in locale.get("custom.ordinal").values()
6969
),
7070
"dddd": "days.wide",
7171
"ddd": "days.abbreviated",
@@ -106,24 +106,24 @@ class Formatter:
106106
# Hour
107107
"HH": lambda dt: f"{dt.hour:02d}",
108108
"H": lambda dt: f"{dt.hour:d}",
109-
"hh": lambda dt: "{:02d}".format(dt.hour % 12 or 12),
110-
"h": lambda dt: "{:d}".format(dt.hour % 12 or 12),
109+
"hh": lambda dt: f"{dt.hour % 12 or 12:02d}",
110+
"h": lambda dt: f"{dt.hour % 12 or 12:d}",
111111
# Minute
112112
"mm": lambda dt: f"{dt.minute:02d}",
113113
"m": lambda dt: f"{dt.minute:d}",
114114
# Second
115115
"ss": lambda dt: f"{dt.second:02d}",
116116
"s": lambda dt: f"{dt.second:d}",
117117
# Fractional second
118-
"S": lambda dt: "{:01d}".format(dt.microsecond // 100000),
119-
"SS": lambda dt: "{:02d}".format(dt.microsecond // 10000),
120-
"SSS": lambda dt: "{:03d}".format(dt.microsecond // 1000),
121-
"SSSS": lambda dt: "{:04d}".format(dt.microsecond // 100),
122-
"SSSSS": lambda dt: "{:05d}".format(dt.microsecond // 10),
118+
"S": lambda dt: f"{dt.microsecond // 100000:01d}",
119+
"SS": lambda dt: f"{dt.microsecond // 10000:02d}",
120+
"SSS": lambda dt: f"{dt.microsecond // 1000:03d}",
121+
"SSSS": lambda dt: f"{dt.microsecond // 100:04d}",
122+
"SSSSS": lambda dt: f"{dt.microsecond // 10:05d}",
123123
"SSSSSS": lambda dt: f"{dt.microsecond:06d}",
124124
# Timestamp
125125
"X": lambda dt: f"{dt.int_timestamp:d}",
126-
"x": lambda dt: "{:d}".format(dt.int_timestamp * 1000 + dt.microsecond // 1000),
126+
"x": lambda dt: f"{dt.int_timestamp * 1000 + dt.microsecond // 1000:d}",
127127
# Timezone
128128
"zz": lambda dt: "{}".format(dt.tzname() if dt.tzinfo is not None else ""),
129129
"z": lambda dt: "{}".format(dt.timezone_name or ""),

0 commit comments

Comments
 (0)