-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent the 'u' prefix on keys #224
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the comments.
@@ -0,0 +1,5 @@ | |||
def to_utf8_py2(data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this to util.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What errors are you getting ? Is it due to circular dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -260,12 +260,14 @@ def _compile_mapping(self, schema, invalid_msg=None): | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the imports to top.
@@ -809,6 +811,8 @@ class Marker(object): | |||
"""Mark nodes for special treatment.""" | |||
|
|||
def __init__(self, schema_, msg=None): | |||
from .encoding import to_utf8_py2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the imports to top
|
||
|
||
def test_to_utf8_py2(): | ||
import six |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the imports to top
@@ -0,0 +1,5 @@ | |||
def to_utf8_py2(data): | |||
import sys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this import to top
@@ -50,5 +50,6 @@ | |||
], | |||
install_requires=[ | |||
'setuptools >= 0.6b1', | |||
'six >= 1.10' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add it in requirements.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a requirements.txt from the fork?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am making one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will have to update setup.py
also for adding requirements.txt
to install_requires.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What errors are you getting ? Is it due to circular dependency?
@@ -8,6 +8,8 @@ | |||
validate, ExactSequence, Equal, Unordered | |||
) | |||
from voluptuous.humanize import humanize_error | |||
from voluptuous.encoding import to_utf8_py2 | |||
import six |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the failing tests and the comments.
@@ -0,0 +1,2 @@ | |||
nose==1.3.7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can now remove requirements.txt
since this is not a dependency on voluptuous but a dependency on tests.
@@ -22,6 +22,13 @@ | |||
|
|||
description = long_description.splitlines()[0].strip() | |||
|
|||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert it back to original setup.py
1 similar comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the comments and squash the commits
@@ -22,7 +22,6 @@ | |||
|
|||
description = long_description.splitlines()[0].strip() | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this change as well
return data | ||
|
||
|
||
if sys.version_info < (3,): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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