Skip to content

Commit

Permalink
Merge pull request #17 from grantps/gps-add-type
Browse files Browse the repository at this point in the history
Re-establish ability to tell numbers from strings etc
  • Loading branch information
H. Chase Stevens authored May 11, 2020
2 parents 68f553e + a165d1f commit 1e0efb9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions astpath/asts.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def convert_to_xml(node, omit_docstrings=False, node_mappings=None):
)

elif field_value is not None:
## add type attribute e.g. so we can distinguish strings from numbers etc
## in older Python (< 3.8) type could be identified by Str vs Num and s vs n etc
## e.g. <Constant lineno="1" col_offset="6" type="int" value="1"/>
_set_encoded_literal(
partial(xml_node.set, 'type'),
type(field_value).__name__
)
_set_encoded_literal(
partial(xml_node.set, field_name),
field_value
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
setup(
name='astpath',
packages=['astpath'],
version='0.9.0',
version='0.9.1',
description='A query language for Python abstract syntax trees',
license='MIT',
author='H. Chase Stevens',
Expand Down

0 comments on commit 1e0efb9

Please sign in to comment.