Skip to content
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

Merged
merged 2 commits into from
Sep 29, 2016
Merged

Prevent the 'u' prefix on keys #224

merged 2 commits into from
Sep 29, 2016

Conversation

jmwri
Copy link
Contributor

@jmwri jmwri commented Sep 28, 2016

Fixes #218

@coveralls
Copy link

coveralls commented Sep 28, 2016

Coverage Status

Coverage decreased (-3.2%) to 91.485% when pulling 902e715 on jmwri:master into 987fd98 on alecthomas:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 94.463% when pulling 6069824 on jmwri:master into 987fd98 on alecthomas:master.

4 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 94.463% when pulling 6069824 on jmwri:master into 987fd98 on alecthomas:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 94.463% when pulling 6069824 on jmwri:master into 987fd98 on alecthomas:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 94.463% when pulling 6069824 on jmwri:master into 987fd98 on alecthomas:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 94.463% when pulling 6069824 on jmwri:master into 987fd98 on alecthomas:master.

@tusharmakkar08
Copy link
Collaborator

Hey @jmwri

Travis build is failing. Please update the PR.

Thanks

@coveralls
Copy link

coveralls commented Sep 28, 2016

Coverage Status

Coverage increased (+0.05%) to 94.743% when pulling 5a9e2ee on jmwri:master into 987fd98 on alecthomas:master.

@coveralls
Copy link

coveralls commented Sep 28, 2016

Coverage Status

Coverage increased (+0.05%) to 94.743% when pulling 4d58148 on jmwri:master into 987fd98 on alecthomas:master.

@jmwri
Copy link
Contributor Author

jmwri commented Sep 28, 2016

@tusharmakkar08 Sorry about that, had some issues with 3.2. I've added six to install_requires.

Copy link
Collaborator

@tusharmakkar08 tusharmakkar08 left a 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):
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Contributor Author

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

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'
Copy link
Collaborator

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am making one.

@coveralls
Copy link

coveralls commented Sep 28, 2016

Coverage Status

Coverage increased (+0.05%) to 94.737% when pulling cdaac81 on jmwri:master into 987fd98 on alecthomas:master.

@coveralls
Copy link

coveralls commented Sep 28, 2016

Coverage Status

Coverage increased (+0.05%) to 94.743% when pulling 8762e73 on jmwri:master into 987fd98 on alecthomas:master.

Copy link
Collaborator

@tusharmakkar08 tusharmakkar08 left a 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
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem

Copy link
Collaborator

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):
Copy link
Collaborator

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
Copy link
Collaborator

@tusharmakkar08 tusharmakkar08 Sep 29, 2016

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

Copy link
Contributor Author

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.

@tusharmakkar08
Copy link
Collaborator

@jmwri : There are few conflicts. Please resolve the conflicts and update the PR.

@coveralls
Copy link

coveralls commented Sep 29, 2016

Coverage Status

Coverage increased (+0.08%) to 94.815% when pulling 7e05824 on jmwri:master into 8f5a41b on alecthomas:master.

Copy link
Collaborator

@tusharmakkar08 tusharmakkar08 left a 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
Copy link
Collaborator

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:
Copy link
Collaborator

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

@coveralls
Copy link

coveralls commented Sep 29, 2016

Coverage Status

Coverage increased (+0.1%) to 94.842% when pulling 6482aa6 on jmwri:master into 8f5a41b on alecthomas:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 94.842% when pulling 6266c9e on jmwri:master into 8f5a41b on alecthomas:master.

1 similar comment
@coveralls
Copy link

coveralls commented Sep 29, 2016

Coverage Status

Coverage increased (+0.1%) to 94.842% when pulling 6266c9e on jmwri:master into 8f5a41b on alecthomas:master.

Copy link
Collaborator

@tusharmakkar08 tusharmakkar08 left a 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()


Copy link
Collaborator

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,):
Copy link
Collaborator

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

@coveralls
Copy link

coveralls commented Sep 29, 2016

Coverage Status

Coverage increased (+0.1%) to 94.837% when pulling 0a70407 on jmwri:master into 8f5a41b on alecthomas:master.

@tusharmakkar08 tusharmakkar08 merged commit 6308d04 into alecthomas:master Sep 29, 2016
@tusharmakkar08
Copy link
Collaborator

@jmwri : Merged 🍰

@jmwri
Copy link
Contributor Author

jmwri commented Sep 29, 2016

Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants