Skip to content

Commit 0e3610d

Browse files
authored
allow type(dict(...)), fix #62 (#64)
1 parent ff3bb9f commit 0e3610d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

devtools/prettier.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,12 @@ def _format(self, value: 'Any', indent_current: int, indent_first: bool):
108108
# very blunt check for things that look like dictionaries but do not necessarily inherit from Mapping
109109
# e.g. asyncpg Records
110110
# HELP: are there any other checks we should include here?
111-
if hasattr(value, '__getitem__') and hasattr(value, 'items') and callable(value.items):
111+
if (
112+
hasattr(value, '__getitem__')
113+
and hasattr(value, 'items')
114+
and callable(value.items)
115+
and not type(value) == type
116+
):
112117
self._format_dict(value, value_repr, indent_current, indent_new)
113118
return
114119

tests/test_prettier.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,7 @@ def test_asyncpg_record():
358358
" 'b': 42,\n"
359359
"})>"
360360
)
361+
362+
363+
def test_dict_type():
364+
assert pformat(type({1: 2})) == "<class 'dict'>"

0 commit comments

Comments
 (0)