Prevent the 'u' prefix on keys#224
Prevent the 'u' prefix on keys#224tusharmakkar08 merged 2 commits intoalecthomas:masterfrom jmwri:master
Conversation
4 similar comments
|
Hey @jmwri Travis build is failing. Please update the PR. Thanks |
|
@tusharmakkar08 Sorry about that, had some issues with 3.2. I've added six to install_requires. |
tusharmakkar08
left a comment
There was a problem hiding this comment.
Please fix the comments.
| @@ -0,0 +1,5 @@ | |||
| def to_utf8_py2(data): | |||
There was a problem hiding this comment.
Can we move this to util.py?
There was a problem hiding this comment.
I'm having some trouble with this. When I move the function I'm getting lots of doctest errors.
There was a problem hiding this comment.
What errors are you getting ? Is it due to circular dependency?
There was a problem hiding this comment.
Lots of AttributeErrors and NameErrors:
File "/Users/jim/Projects/voluptuous/README.md", line 578, in README.md Failed example: schema([6]) Exception raised: Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 1315, in __run compileflags, 1) in test.globs File "<doctest README.md[106]>", line 1, in <module> schema([6]) NameError: name 'schema' is not defined
Seems to be caused by the import at the top of schema_builder.py. If I move the import to the functions where they are used then it's fine.
Having checked util.py it is importing schema_builder.py so yes, it looks like a circular import.
| candidates = list(_iterate_mapping_candidates(_compiled_schema)) | ||
|
|
||
| def validate_mapping(path, iterable, out): | ||
| from .encoding import to_utf8_py2 |
There was a problem hiding this comment.
Please move the imports to top.
| """Mark nodes for special treatment.""" | ||
|
|
||
| def __init__(self, schema_, msg=None): | ||
| from .encoding import to_utf8_py2 |
There was a problem hiding this comment.
Please move the imports to top
|
|
||
| def test_unicode_key_is_converted_to_utf8_when_in_marker(): | ||
| """Verify that when using unicode key the 'u' prefix is not thrown in the exception""" | ||
| import six |
There was a problem hiding this comment.
Move the imports to top
|
|
||
|
|
||
| def test_unicode_key_is_converted_to_utf8_when_plain_text(): | ||
| import six |
There was a problem hiding this comment.
Move the imports to top
|
|
||
|
|
||
| def test_to_utf8_py2(): | ||
| import six |
There was a problem hiding this comment.
Move the imports to top
| @@ -0,0 +1,5 @@ | |||
| def to_utf8_py2(data): | |||
| import sys | |||
There was a problem hiding this comment.
Move this import to top
| ], | ||
| install_requires=[ | ||
| 'setuptools >= 0.6b1', | ||
| 'six >= 1.10' |
There was a problem hiding this comment.
Add it in requirements.txt
There was a problem hiding this comment.
I don't have a requirements.txt from the fork?
tusharmakkar08
left a comment
There was a problem hiding this comment.
Please reply to the comments and fix the suggestions. Also after that it would be great if you can squash the commits into one.
| @@ -0,0 +1,2 @@ | |||
| nose==1.3.7 | |||
There was a problem hiding this comment.
You will have to update setup.py also for adding requirements.txt to install_requires.
There was a problem hiding this comment.
We can now remove requirements.txt since this is not a dependency on voluptuous but a dependency on tests.
| @@ -0,0 +1,5 @@ | |||
| def to_utf8_py2(data): | |||
There was a problem hiding this comment.
What errors are you getting ? Is it due to circular dependency?
| ) | ||
| from voluptuous.humanize import humanize_error | ||
| from voluptuous.encoding import to_utf8_py2 | ||
| import six |
There was a problem hiding this comment.
Can we get this done without importing six? Because Ideally we don't want voluptuous to have external dependencies. Check this
There was a problem hiding this comment.
I've had to make separate tests for py2 & 3 due to checking for unicode or str objects.
|
@jmwri : There are few conflicts. Please resolve the conflicts and update the PR. |
tusharmakkar08
left a comment
There was a problem hiding this comment.
Please fix the failing tests and the comments.
| @@ -0,0 +1,2 @@ | |||
| nose==1.3.7 | |||
There was a problem hiding this comment.
We can now remove requirements.txt since this is not a dependency on voluptuous but a dependency on tests.
|
|
||
| description = long_description.splitlines()[0].strip() | ||
|
|
||
| try: |
There was a problem hiding this comment.
Please revert it back to original setup.py
1 similar comment
tusharmakkar08
left a comment
There was a problem hiding this comment.
Please fix the comments and squash the commits
|
|
||
| description = long_description.splitlines()[0].strip() | ||
|
|
||
|
|
There was a problem hiding this comment.
Please revert this change as well
| return data | ||
|
|
||
|
|
||
| if sys.version_info < (3,): |
There was a problem hiding this comment.
Why not doing something like:
def u(x):
if sys.version_info < (3, ):
return unicode(x)
else:
return x
# Conflicts: # voluptuous/tests/tests.py
|
@jmwri : Merged 🍰 |
|
Yay! |
Fixes #218