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

Cleanup and 3.x compatibility #5

Merged
merged 11 commits into from
Jul 30, 2016
Merged

Cleanup and 3.x compatibility #5

merged 11 commits into from
Jul 30, 2016

Conversation

chsamlee
Copy link
Contributor

@chsamlee chsamlee commented Jul 30, 2016

Changes:

  • make the module python3-compatible
  • proper implementation of __eq__ and __repr__
  • change LispError to be subclass of LispDict (reason: a lispified error is also a plist, and subclassing allows some duplicate code to be removed)

Fixes #2 and unblocks #3.

@codecov-io
Copy link

codecov-io commented Jul 30, 2016

Current coverage is 91.66% (diff: 92.59%)

Merging #5 into master will increase coverage by 2.13%

@@             master         #5   diff @@
==========================================
  Files             2          2          
  Lines           172        156    -16   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits            154        143    -11   
+ Misses           18         13     -5   
  Partials          0          0          

Powered by Codecov. Last update cd70371...b7b3b85

@chsamlee chsamlee changed the title Make lispify 3.x-compatible Cleanup the module Jul 30, 2016
@chsamlee chsamlee changed the title Cleanup the module Cleanup and 3.x compatibility Jul 30, 2016
@@ -1,6 +1,7 @@
language: python
python:
- "2.7"
- "3.4"
Copy link
Member

Choose a reason for hiding this comment

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

I'd be nice to have travis build across all versions of python:

diff --git a/.travis.yml b/.travis.yml
index 17306a6..116b0a4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,13 @@
 language: python
 python:
+  - "2.6"
   - "2.7"
+  - "3.2"
+  - "3.3"
+  - "3.4"
+  - "3.5"
+  - "3.5-dev" # 3.5 development branch
+  - "nightly" # currently points to 3.6-dev
 install:
   - pip install codecov pep8
   - python setup.py install

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 think we should support 3.2 because very few people use it and 3.2 compatibility is more complicated: the u'unicode string' was removed in 3.0 and only readded in 3.3.

Given that travis relies on volunteers for computing resources, I don't think we should have a build for every version. I think 2.7, 3.3, and nightly should be enough, and maybe 2.6 if that is necessary.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should support 3.2 because very few people use it and 3.2 compatibility is more complicated: the u'unicode string' was removed in 3.0 and only readded in 3.3.

Ok, that sounds reasonable. Why don't you update the README with a list of supported Python versions so that it's clear.

Given that travis relies on volunteers for computing resources

I wouldn't worry about that too much. Millions of projects use Travis, and us using a few more builds is not going to make a difference.

I think 2.7, 3.3, and nightly should be enough, and maybe 2.6 if that is necessary.

Given my above reasoning, how about 2.6, 3.3, 3.4, 3.5, 3.5-dev, and nightly? I think 2.6 might not have codecov. If that's the case, omit the codecov step. I'm not too keen on 2.6, so if it's causing lots of problems, don't worry about it. But the other versions I listed I think we should try to support if possible.

@michaelsilver
Copy link
Member

Awesome job! I'm so glad you figured this out, because I had significant trouble figuring out the details of unicode compatibility across Python 2 and 3. 🎉

In addition to my inline notes, could you please add some documentation to the lispify function explaining what kind of string it returns (depending on the Python version)? I noticed you were wrapping calls to the lispify function with unicode() and str() in the unit tests, but lots of other libraries that depend on lispify just call it bare, without wrapping. So it needs to be obvious to other developers what they get raw out of the lispify function.

@michaelsilver michaelsilver mentioned this pull request Jul 30, 2016
@chsamlee
Copy link
Contributor Author

The behavior of lispify is not changed in this PR, so other users shouldn't have to change their coe. It is the changes in __eq__ that requires wrapping lispify calls in unit tests - the current implementation treats a string s and a LispType object as equal if the object's string representation is same as s. Convenient for testing, but a bad practice regardless.

@michaelsilver
Copy link
Member

It is the changes in __eq__ that requires wrapping lispify calls in unit tests - the current implementation treats a string s and a LispType object as equal if the object's string representation is same as s. Convenient for testing, but a bad practice regardless.

Hmm... I wonder whether there's a way to use a 3rd party library, or the __future__ import to solve this? Alternatively, maybe you could create a wrapper testing function to deal with the str conversion and do a type check?

@chsamlee chsamlee assigned michaelsilver and unassigned chsamlee Jul 30, 2016
@@ -12,3 +12,4 @@ Version numbers `MAJOR.MINOR.PATCH` should follow a system inspired by [semantic
1. PATCH version when you make backwards-compatible bug fixes.

Create a [release](https://help.github.com/articles/creating-releases/) on Github for each new version.
>>>>>>> master
Copy link
Member

Choose a reason for hiding this comment

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

delete

@michaelsilver
Copy link
Member

Other than deleting the accidentally left >>>>>>> master (see in-line note), LGTM! 🚀

(just delete it, and merge, no need to re-review)

@chsamlee chsamlee merged commit 0ef5f44 into master Jul 30, 2016
@chsamlee chsamlee deleted the py3-compat branch July 30, 2016 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants