Skip to content

Commit 5d18e50

Browse files
committed
fixes #574
1 parent b67cf9c commit 5d18e50

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
<!-- do not remove -->
44

5+
## 1.5.46
6+
7+
### New Features
8+
9+
- Provide attr get/set in `XT` ([#572](https://github.com/fastai/fastcore/issues/572))
10+
- Handle non-str types in `to_xml` ([#571](https://github.com/fastai/fastcore/issues/571))
11+
12+
513
## 1.5.45
614

715
### New Features

fastcore/basics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ def _init_state(self):
10621062
class NotStr(GetAttr):
10631063
"Behaves like a `str`, but isn't an instance of one"
10641064
_default = 's'
1065-
def __init__(self, s): self.s = s
1065+
def __init__(self, s): self.s = s.s if isinstance(s, NotStr) else s
10661066
def __repr__(self): return repr(self.s)
10671067
def __str__(self): return self.s
10681068
def __add__(self, b): return NotStr(self.s+str(b))

nbs/01_basics.ipynb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@
782782
"text/markdown": [
783783
"---\n",
784784
"\n",
785-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L141){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
785+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L145){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
786786
"\n",
787787
"#### ignore_exceptions\n",
788788
"\n",
@@ -793,7 +793,7 @@
793793
"text/plain": [
794794
"---\n",
795795
"\n",
796-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L141){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
796+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L145){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
797797
"\n",
798798
"#### ignore_exceptions\n",
799799
"\n",
@@ -2752,7 +2752,7 @@
27522752
"text/markdown": [
27532753
"---\n",
27542754
"\n",
2755-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L492){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
2755+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L496){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
27562756
"\n",
27572757
"#### GetAttr\n",
27582758
"\n",
@@ -2763,7 +2763,7 @@
27632763
"text/plain": [
27642764
"---\n",
27652765
"\n",
2766-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L492){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
2766+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L496){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
27672767
"\n",
27682768
"#### GetAttr\n",
27692769
"\n",
@@ -4298,7 +4298,7 @@
42984298
"text/markdown": [
42994299
"---\n",
43004300
"\n",
4301-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L792){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
4301+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L806){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
43024302
"\n",
43034303
"#### fastuple\n",
43044304
"\n",
@@ -4309,7 +4309,7 @@
43094309
"text/plain": [
43104310
"---\n",
43114311
"\n",
4312-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L792){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
4312+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L806){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
43134313
"\n",
43144314
"#### fastuple\n",
43154315
"\n",
@@ -4383,7 +4383,7 @@
43834383
"text/markdown": [
43844384
"---\n",
43854385
"\n",
4386-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L811){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
4386+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L825){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
43874387
"\n",
43884388
"##### fastuple.add\n",
43894389
"\n",
@@ -4394,7 +4394,7 @@
43944394
"text/plain": [
43954395
"---\n",
43964396
"\n",
4397-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L811){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
4397+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L825){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
43984398
"\n",
43994399
"##### fastuple.add\n",
44004400
"\n",
@@ -4433,7 +4433,7 @@
44334433
"text/markdown": [
44344434
"---\n",
44354435
"\n",
4436-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L807){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
4436+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L821){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
44374437
"\n",
44384438
"##### fastuple.mul\n",
44394439
"\n",
@@ -4444,7 +4444,7 @@
44444444
"text/plain": [
44454445
"---\n",
44464446
"\n",
4447-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L807){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
4447+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L821){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
44484448
"\n",
44494449
"##### fastuple.mul\n",
44504450
"\n",
@@ -4594,7 +4594,7 @@
45944594
"text/markdown": [
45954595
"---\n",
45964596
"\n",
4597-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L838){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
4597+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L852){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
45984598
"\n",
45994599
"### bind\n",
46004600
"\n",
@@ -4605,7 +4605,7 @@
46054605
"text/plain": [
46064606
"---\n",
46074607
"\n",
4608-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L838){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
4608+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L852){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
46094609
"\n",
46104610
"### bind\n",
46114611
"\n",
@@ -5570,23 +5570,23 @@
55705570
"text/markdown": [
55715571
"---\n",
55725572
"\n",
5573-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L999){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
5573+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1024){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
55745574
"\n",
55755575
"#### ImportEnum\n",
55765576
"\n",
5577-
"> ImportEnum (new_class_name, names, module=None, qualname=None, type=None,\n",
5577+
"> ImportEnum (value, names=None, module=None, qualname=None, type=None,\n",
55785578
"> start=1, boundary=None)\n",
55795579
"\n",
55805580
"*An `Enum` that can have its values imported*"
55815581
],
55825582
"text/plain": [
55835583
"---\n",
55845584
"\n",
5585-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L999){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
5585+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1024){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
55865586
"\n",
55875587
"#### ImportEnum\n",
55885588
"\n",
5589-
"> ImportEnum (new_class_name, names, module=None, qualname=None, type=None,\n",
5589+
"> ImportEnum (value, names=None, module=None, qualname=None, type=None,\n",
55905590
"> start=1, boundary=None)\n",
55915591
"\n",
55925592
"*An `Enum` that can have its values imported*"
@@ -5635,23 +5635,23 @@
56355635
"text/markdown": [
56365636
"---\n",
56375637
"\n",
5638-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1007){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
5638+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1032){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
56395639
"\n",
56405640
"#### StrEnum\n",
56415641
"\n",
5642-
"> StrEnum (new_class_name, names, module=None, qualname=None, type=None,\n",
5642+
"> StrEnum (value, names=None, module=None, qualname=None, type=None,\n",
56435643
"> start=1, boundary=None)\n",
56445644
"\n",
56455645
"*An `ImportEnum` that behaves like a `str`*"
56465646
],
56475647
"text/plain": [
56485648
"---\n",
56495649
"\n",
5650-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1007){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
5650+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1032){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
56515651
"\n",
56525652
"#### StrEnum\n",
56535653
"\n",
5654-
"> StrEnum (new_class_name, names, module=None, qualname=None, type=None,\n",
5654+
"> StrEnum (value, names=None, module=None, qualname=None, type=None,\n",
56555655
"> start=1, boundary=None)\n",
56565656
"\n",
56575657
"*An `ImportEnum` that behaves like a `str`*"
@@ -5736,7 +5736,7 @@
57365736
"text/markdown": [
57375737
"---\n",
57385738
"\n",
5739-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1017){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
5739+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1042){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
57405740
"\n",
57415741
"#### Stateful\n",
57425742
"\n",
@@ -5747,7 +5747,7 @@
57475747
"text/plain": [
57485748
"---\n",
57495749
"\n",
5750-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1017){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
5750+
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/basics.py#L1042){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
57515751
"\n",
57525752
"#### Stateful\n",
57535753
"\n",
@@ -5849,7 +5849,7 @@
58495849
"class NotStr(GetAttr):\n",
58505850
" \"Behaves like a `str`, but isn't an instance of one\"\n",
58515851
" _default = 's'\n",
5852-
" def __init__(self, s): self.s = s\n",
5852+
" def __init__(self, s): self.s = s.s if isinstance(s, NotStr) else s\n",
58535853
" def __repr__(self): return repr(self.s)\n",
58545854
" def __str__(self): return self.s\n",
58555855
" def __add__(self, b): return NotStr(self.s+str(b))\n",

0 commit comments

Comments
 (0)