furl doesn't type-hint itself as Text
- Dominant language
- Python
- Stars
- 2.8k
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
If `furl` were a `typing.Text`, it would work with static type checkers/hinters.
I like that the following works:
```python
url_obj = furl('http://www.google.com')
response = requests.get(url_obj)
```
However, the static checker (I'm using PyRight) complains that `furl.furl.furl` does not match `request.post`'s signature for `Text | bytes`.
I'm newish to Python still, but I think it would require adding the superclass:
```python
from typing import Text
# at https://github.com/gruns/furl/blob/d0bee9a27d7f432b047194a94f64cd4ff0319f6a/furl/furl.py#L1337-L1338
class furl(URLPathCompositionInterface, QueryCompositionInterface,
FragmentCompositionInterface, UnicodeMixin, Text):
```
Then using a factory function named `furl`.
In the meantime, this is my workaround to satisfy the checker:
```python
# in my utils/__init__.py
from typing import Text
from furl import furl as FurlOrig
class Furl(FurlOrig, Text): # bonus: capitalized class name less surprising
pass
def furl(*args, **kwargs) -> Furl:
return Furl(*args, **kwargs)
# usage in other files
from utils import furl
# use `furl` as normal
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.