Skip to content

Commit

Permalink
fixes #574
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Jun 16, 2024
1 parent b67cf9c commit 5d18e50
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

<!-- do not remove -->

## 1.5.46

### New Features

- Provide attr get/set in `XT` ([#572](https://github.com/fastai/fastcore/issues/572))
- Handle non-str types in `to_xml` ([#571](https://github.com/fastai/fastcore/issues/571))


## 1.5.45

### New Features
Expand Down
2 changes: 1 addition & 1 deletion fastcore/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ def _init_state(self):
class NotStr(GetAttr):
"Behaves like a `str`, but isn't an instance of one"
_default = 's'
def __init__(self, s): self.s = s
def __init__(self, s): self.s = s.s if isinstance(s, NotStr) else s
def __repr__(self): return repr(self.s)
def __str__(self): return self.s
def __add__(self, b): return NotStr(self.s+str(b))
Expand Down
46 changes: 23 additions & 23 deletions nbs/01_basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L141){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L145){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### ignore_exceptions\n",
"\n",
Expand All @@ -793,7 +793,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L141){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L145){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### ignore_exceptions\n",
"\n",
Expand Down Expand Up @@ -2752,7 +2752,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L492){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L496){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### GetAttr\n",
"\n",
Expand All @@ -2763,7 +2763,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L492){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L496){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### GetAttr\n",
"\n",
Expand Down Expand Up @@ -4298,7 +4298,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L792){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L806){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### fastuple\n",
"\n",
Expand All @@ -4309,7 +4309,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L792){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L806){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### fastuple\n",
"\n",
Expand Down Expand Up @@ -4383,7 +4383,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L811){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L825){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"##### fastuple.add\n",
"\n",
Expand All @@ -4394,7 +4394,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L811){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L825){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"##### fastuple.add\n",
"\n",
Expand Down Expand Up @@ -4433,7 +4433,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L807){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L821){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"##### fastuple.mul\n",
"\n",
Expand All @@ -4444,7 +4444,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L807){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L821){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"##### fastuple.mul\n",
"\n",
Expand Down Expand Up @@ -4594,7 +4594,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L838){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L852){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"### bind\n",
"\n",
Expand All @@ -4605,7 +4605,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L838){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L852){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"### bind\n",
"\n",
Expand Down Expand Up @@ -5570,23 +5570,23 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L999){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1024){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### ImportEnum\n",
"\n",
"> ImportEnum (new_class_name, names, module=None, qualname=None, type=None,\n",
"> ImportEnum (value, names=None, module=None, qualname=None, type=None,\n",
"> start=1, boundary=None)\n",
"\n",
"*An `Enum` that can have its values imported*"
],
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L999){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1024){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### ImportEnum\n",
"\n",
"> ImportEnum (new_class_name, names, module=None, qualname=None, type=None,\n",
"> ImportEnum (value, names=None, module=None, qualname=None, type=None,\n",
"> start=1, boundary=None)\n",
"\n",
"*An `Enum` that can have its values imported*"
Expand Down Expand Up @@ -5635,23 +5635,23 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1007){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1032){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### StrEnum\n",
"\n",
"> StrEnum (new_class_name, names, module=None, qualname=None, type=None,\n",
"> StrEnum (value, names=None, module=None, qualname=None, type=None,\n",
"> start=1, boundary=None)\n",
"\n",
"*An `ImportEnum` that behaves like a `str`*"
],
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1007){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1032){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### StrEnum\n",
"\n",
"> StrEnum (new_class_name, names, module=None, qualname=None, type=None,\n",
"> StrEnum (value, names=None, module=None, qualname=None, type=None,\n",
"> start=1, boundary=None)\n",
"\n",
"*An `ImportEnum` that behaves like a `str`*"
Expand Down Expand Up @@ -5736,7 +5736,7 @@
"text/markdown": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1017){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1042){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### Stateful\n",
"\n",
Expand All @@ -5747,7 +5747,7 @@
"text/plain": [
"---\n",
"\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1017){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1042){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
"\n",
"#### Stateful\n",
"\n",
Expand Down Expand Up @@ -5849,7 +5849,7 @@
"class NotStr(GetAttr):\n",
" \"Behaves like a `str`, but isn't an instance of one\"\n",
" _default = 's'\n",
" def __init__(self, s): self.s = s\n",
" def __init__(self, s): self.s = s.s if isinstance(s, NotStr) else s\n",
" def __repr__(self): return repr(self.s)\n",
" def __str__(self): return self.s\n",
" def __add__(self, b): return NotStr(self.s+str(b))\n",
Expand Down

0 comments on commit 5d18e50

Please sign in to comment.