arrow icon indicating copy to clipboard operation
arrow copied to clipboard

Fix type signature of Arrow.__getattr__

Open salty-horse opened this issue 1 year ago • 0 comments

Pull Request Checklist

  • [ ] 🧪 Added tests for changed code.
  • [x] 🛠️ All tests pass when run locally (run tox or make test to find out!).
  • [x] 🧹 All linting checks pass when run locally (run tox -e lint or make lint to find out!).
  • [ ] 📚 Updated documentation for changed code.
  • [x] ⏩ 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.

salty-horse avatar Feb 20 '24 09:02 salty-horse