Skip to content

Fix type signature of Arrow.__getattr__#1171

Merged
jadchaar merged 2 commits intoarrow-py:masterfrom
salty-horse:getattr_type
Oct 19, 2024
Merged

Fix type signature of Arrow.__getattr__#1171
jadchaar merged 2 commits intoarrow-py:masterfrom
salty-horse:getattr_type

Conversation

@salty-horse
Copy link
Copy Markdown
Contributor

Pull Request Checklist

  • 🧪 Added tests for changed code.
  • 🛠️ All tests pass when run locally (run tox or make test to find out!).
  • 🧹 All linting checks pass when run locally (run tox -e lint or make lint to find out!).
  • 📚 Updated documentation for changed code.
  • ⏩ Code is up-to-date with the master branch.

Description of Changes

Arrow's __getattr__ provides access to datetime attributes that aren't handled by Arrow.
It has this signature:

def __getattr__(self, name: str) -> int

It should return Any, as not all attributes from datetime are ints.

For example, in arrow.now().tzname(), tzname is a function.

I noticed that __getattr__ implements two undocumented attributes: week and quarter. The should be split into their own methods, with a docstring.

@jadchaar jadchaar merged commit d5bd7db into arrow-py:master Oct 19, 2024
onerandomusername added a commit to onerandomusername/monty-python that referenced this pull request Oct 22, 2025
Bumps [arrow](https://github.com/arrow-py/arrow) from 1.3.0 to 1.4.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/arrow-py/arrow/blob/master/CHANGELOG.rst">arrow's
changelog</a>.</em></p>
<blockquote>
<h2>1.4.0 (2025-10-18)</h2>
<ul>
<li>[ADDED] Added <code>week_start</code> parameter to
<code>floor()</code> and <code>ceil()</code> methods. <code>PR
[#1222](arrow-py/arrow#1222)
&lt;https://github.com/arrow-py/arrow/pull/1222&gt;</code>_</li>
<li>[ADDED] Added <code>FORMAT_RFC3339_STRICT</code> with a T separator.
<code>PR [#1201](arrow-py/arrow#1201)
&lt;https://github.com/arrow-py/arrow/pull/1201&gt;</code>_</li>
<li>[ADDED] Added Macedonian in Latin locale support. <code>PR
[#1200](arrow-py/arrow#1200)
&lt;https://github.com/arrow-py/arrow/pull/1200&gt;</code>_</li>
<li>[ADDED] Added Persian/Farsi locale support. <code>PR
[#1190](arrow-py/arrow#1190)
&lt;https://github.com/arrow-py/arrow/pull/1190&gt;</code>_</li>
<li>[ADDED] Added week and weeks to Thai locale timeframes. <code>PR
[#1218](arrow-py/arrow#1218)
&lt;https://github.com/arrow-py/arrow/pull/1218&gt;</code>_</li>
<li>[ADDED] Added weeks to Catalan locale. <code>PR
[#1189](arrow-py/arrow#1189)
&lt;https://github.com/arrow-py/arrow/pull/1189&gt;</code>_</li>
<li>[ADDED] Added Persian names of months, month-abbreviations and
day-abbreviations in Gregorian calendar. <code>PR
[#1172](arrow-py/arrow#1172)
&lt;https://github.com/arrow-py/arrow/pull/1172&gt;</code>_</li>
<li>[CHANGED] Migrated Arrow to use ZoneInfo for timezones instead of
pytz. <code>PR [#1217](arrow-py/arrow#1217)
&lt;https://github.com/arrow-py/arrow/pull/1217&gt;</code>_</li>
<li>[FIXED] Fixed humanize month limits. <code>PR
[#1224](arrow-py/arrow#1224)
&lt;https://github.com/arrow-py/arrow/pull/1224&gt;</code>_</li>
<li>[FIXED] Fixed type hint of <code>Arrow.__getattr__</code>. <code>PR
[#1171](arrow-py/arrow#1171)
&lt;https://github.com/arrow-py/arrow/pull/1171&gt;</code>_</li>
<li>[FIXED] Fixed spelling and removed poorly used expressions in Korean
locale. <code>PR [#1181](arrow-py/arrow#1181)
&lt;https://github.com/arrow-py/arrow/pull/1181&gt;</code>_</li>
<li>[FIXED] Updated <code>shift()</code> method for issue <a
href="https://redirect.github.com/arrow-py/arrow/issues/1145">#1145</a>.
<code>PR [#1194](arrow-py/arrow#1194)
&lt;https://github.com/arrow-py/arrow/pull/1194&gt;</code>_</li>
<li>[FIXED] Improved Greek locale translations (seconds, days,
&quot;ago&quot;, and month typo). <code>PR
[#1184](arrow-py/arrow#1184)
&lt;https://github.com/arrow-py/arrow/pull/1184&gt;</code><em>, <code>PR
[#1186](arrow-py/arrow#1186)
&lt;https://github.com/arrow-py/arrow/pull/1186&gt;</code></em></li>
<li>[FIXED] Addressed <code>datetime.utcnow</code> deprecation warning.
<code>PR [#1182](arrow-py/arrow#1182)
&lt;https://github.com/arrow-py/arrow/pull/1182&gt;</code>_</li>
<li>[INTERNAL] Added codecov test results. <code>PR
[#1223](arrow-py/arrow#1223)
&lt;https://github.com/arrow-py/arrow/pull/1223&gt;</code>_</li>
<li>[INTERNAL] Updated CI dependencies (actions/setup-python,
actions/checkout, codecov/codecov-action, actions/cache).</li>
<li>[INTERNAL] Added docstrings to parser.py. <code>PR
[#1010](arrow-py/arrow#1010)
&lt;https://github.com/arrow-py/arrow/pull/1010&gt;</code>_</li>
<li>[INTERNAL] Updated Python versions support and bumped CI
dependencies. <code>PR
[#1177](arrow-py/arrow#1177)
&lt;https://github.com/arrow-py/arrow/pull/1177&gt;</code>_</li>
<li>[INTERNAL] Added dependabot for GitHub actions. <code>PR
[#1193](arrow-py/arrow#1193)
&lt;https://github.com/arrow-py/arrow/pull/1193&gt;</code>_</li>
<li>[INTERNAL] Moved dateutil types to test requirements. <code>PR
[#1183](arrow-py/arrow#1183)
&lt;https://github.com/arrow-py/arrow/pull/1183&gt;</code>_</li>
<li>[INTERNAL] Added documentation link for <code>arrow.format</code>.
<code>PR [#1180](arrow-py/arrow#1180)
&lt;https://github.com/arrow-py/arrow/pull/1180&gt;</code>_</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/arrow-py/arrow/commit/2c1f5185ad66bf3b1cf8c0812f4b4fe65ac46656"><code>2c1f518</code></a>
Bump release CI flow to use Python 3.14</li>
<li><a
href="https://github.com/arrow-py/arrow/commit/2483bfea4ec8a4da609036aba3ce1b32cb571875"><code>2483bfe</code></a>
Bump changelog date</li>
<li><a
href="https://github.com/arrow-py/arrow/commit/c61de9299733da6d4a7e8badabae43684a3f9da2"><code>c61de92</code></a>
Bump version and add changelog (<a
href="https://redirect.github.com/arrow-py/arrow/issues/1228">#1228</a>)</li>
<li><a
href="https://github.com/arrow-py/arrow/commit/c3bb589536b283e3e3886d1d6bc01a6374c8e656"><code>c3bb589</code></a>
Update pypy CI version and update pre-commit dependencies</li>
<li><a
href="https://github.com/arrow-py/arrow/commit/85cd905332d108303da1cbd0f2336fcae058147f"><code>85cd905</code></a>
Run tests on next Python release (<a
href="https://redirect.github.com/arrow-py/arrow/issues/1227">#1227</a>)</li>
<li><a
href="https://github.com/arrow-py/arrow/commit/4c8c44aefc0e5504b9c3cbf0d6adbb0ec4aa4571"><code>4c8c44a</code></a>
Add week_start parameter to floor() and ceil() (<a
href="https://redirect.github.com/arrow-py/arrow/issues/1222">#1222</a>)</li>
<li><a
href="https://github.com/arrow-py/arrow/commit/7ccbe66122ca53d90acf9c69c37aa95c81a1fe89"><code>7ccbe66</code></a>
add codecov test results (<a
href="https://redirect.github.com/arrow-py/arrow/issues/1223">#1223</a>)</li>
<li><a
href="https://github.com/arrow-py/arrow/commit/05cd9b47d0db1c22b44cb739832f1b9701855313"><code>05cd9b4</code></a>
fix humanize month limits (<a
href="https://redirect.github.com/arrow-py/arrow/issues/1224">#1224</a>)</li>
<li><a
href="https://github.com/arrow-py/arrow/commit/ea756ea779468b0c6a9f45439dc05cfd5e71ee1e"><code>ea756ea</code></a>
Bump actions/setup-python from 5 to 6 (<a
href="https://redirect.github.com/arrow-py/arrow/issues/1220">#1220</a>)</li>
<li><a
href="https://github.com/arrow-py/arrow/commit/86f7520f15b2dd46f9c49f71ce5c15bbc537ed67"><code>86f7520</code></a>
Bump actions/checkout from 4 to 5 (<a
href="https://redirect.github.com/arrow-py/arrow/issues/1219">#1219</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/arrow-py/arrow/compare/1.3.0...1.4.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=arrow&package-manager=uv&previous-version=1.3.0&new-version=1.4.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: onerandomusername <me@arielle.codes>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants