remove references to '2to3' in doc, travis, etc

This commit is contained in:
Bastien Gérard 2019-06-15 14:37:47 +02:00
parent 009f9a2b14
commit a3e432eb68
5 changed files with 24 additions and 18 deletions

View File

@ -5,17 +5,12 @@ pylint:
options: options:
additional-builtins: additional-builtins:
# add xrange and long as valid built-ins. In Python 3, xrange is # add long as valid built-ins.
# translated into range and long is translated into int via 2to3 (see
# "use_2to3" in setup.py). This should be removed when we drop Python
# 2 support (which probably won't happen any time soon).
- xrange
- long - long
pyflakes: pyflakes:
disable: disable:
# undefined variables are already covered by pylint (and exclude # undefined variables are already covered by pylint (and exclude long)
# xrange & long)
- F821 - F821
ignore-paths: ignore-paths:

View File

@ -73,7 +73,7 @@ install:
before_script: before_script:
- mkdir ${PWD}/mongodb-linux-x86_64-${MONGODB}/data - mkdir ${PWD}/mongodb-linux-x86_64-${MONGODB}/data
- ${PWD}/mongodb-linux-x86_64-${MONGODB}/bin/mongod --dbpath ${PWD}/mongodb-linux-x86_64-${MONGODB}/data --logpath ${PWD}/mongodb-linux-x86_64-${MONGODB}/mongodb.log --fork - ${PWD}/mongodb-linux-x86_64-${MONGODB}/bin/mongod --dbpath ${PWD}/mongodb-linux-x86_64-${MONGODB}/data --logpath ${PWD}/mongodb-linux-x86_64-${MONGODB}/mongodb.log --fork
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then flake8 .; else echo "flake8 only runs on py27"; fi # Run flake8 for Python 2.7 only - if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then flake8 .; else echo "flake8 only runs on py37"; fi # Run flake8 for Python 3.7 only
- if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then black --check .; else echo "black only runs on py37"; fi # Run black for Python 3.7 only - if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then black --check .; else echo "black only runs on py37"; fi # Run black for Python 3.7 only
- mongo --eval 'db.version();' # Make sure mongo is awake - mongo --eval 'db.version();' # Make sure mongo is awake
@ -84,7 +84,7 @@ script:
# 0% coverage. That's caused by 'use_2to3', which builds the py3-compatible # 0% coverage. That's caused by 'use_2to3', which builds the py3-compatible
# code in a separate dir and runs tests on that. # code in a separate dir and runs tests on that.
after_success: after_success:
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then coveralls --verbose; else echo "coveralls only sent for py27"; fi - coveralls --verbose
notifications: notifications:
irc: irc.freenode.org#mongoengine irc: irc.freenode.org#mongoengine

View File

@ -22,11 +22,19 @@ Supported Interpreters
MongoEngine supports CPython 2.7 and newer. Language MongoEngine supports CPython 2.7 and newer. Language
features not supported by all interpreters can not be used. features not supported by all interpreters can not be used.
The codebase is written in python 2 so you must be using python 2 The codebase is written in a compatible manner for python 2 & 3 so it
when developing new features. Compatibility of the library with Python 3 is important that this is taken into account when it comes to discrepencies
relies on the 2to3 package that gets executed as part of the installation between the 2 versions (check this https://python-future.org/compatible_idioms.html).
build. You should ensure that your code is properly converted by Travis runs run the tests against the different versions as a safety net.
`2to3 <http://docs.python.org/library/2to3.html>`_.
Python 2/3 compatibility
----------------------
The codebase is written in a compatible manner for python 2 & 3 so it
is important that this is taken into account when it comes to discrepencies
between the 2 versions (check this https://python-future.org/compatible_idioms.html).
Travis runs run the tests against the different versions as a safety net.
Style Guide Style Guide
----------- -----------

View File

@ -3,13 +3,17 @@ import timeit
def main(): def main():
setup = """ setup = """
from builtins import range
from pymongo import MongoClient from pymongo import MongoClient
connection = MongoClient() connection = MongoClient()
connection.drop_database('mongoengine_benchmark_test') connection.drop_database('mongoengine_benchmark_test')
""" """
stmt = """ stmt = """
from pymongo import MongoClient from pymongo import MongoClient
connection = MongoClient() connection = MongoClient()
db = connection.mongoengine_benchmark_test db = connection.mongoengine_benchmark_test
@ -55,7 +59,10 @@ myNoddys = noddy.find()
print("{}s".format(t.timeit(1))) print("{}s".format(t.timeit(1)))
setup = """ setup = """
from builtins import range
from pymongo import MongoClient from pymongo import MongoClient
connection = MongoClient() connection = MongoClient()
connection.drop_database('mongoengine_benchmark_test') connection.drop_database('mongoengine_benchmark_test')
connection.close() connection.close()

View File

@ -71,7 +71,6 @@ class EmbeddedDocument(six.with_metaclass(DocumentMetaclass, BaseDocument)):
__slots__ = ("_instance",) __slots__ = ("_instance",)
# The __metaclass__ attribute is removed by 2to3 when running with Python3
# my_metaclass is defined so that metaclass can be queried in Python 2 & 3 # my_metaclass is defined so that metaclass can be queried in Python 2 & 3
my_metaclass = DocumentMetaclass my_metaclass = DocumentMetaclass
@ -156,7 +155,6 @@ class Document(six.with_metaclass(TopLevelDocumentMetaclass, BaseDocument)):
in the :attr:`meta` dictionary. in the :attr:`meta` dictionary.
""" """
# The __metaclass__ attribute is removed by 2to3 when running with Python3
# my_metaclass is defined so that metaclass can be queried in Python 2 & 3 # my_metaclass is defined so that metaclass can be queried in Python 2 & 3
my_metaclass = TopLevelDocumentMetaclass my_metaclass = TopLevelDocumentMetaclass
@ -1045,7 +1043,6 @@ class DynamicDocument(six.with_metaclass(TopLevelDocumentMetaclass, Document)):
There is one caveat on Dynamic Documents: undeclared fields cannot start with `_` There is one caveat on Dynamic Documents: undeclared fields cannot start with `_`
""" """
# The __metaclass__ attribute is removed by 2to3 when running with Python3
# my_metaclass is defined so that metaclass can be queried in Python 2 & 3 # my_metaclass is defined so that metaclass can be queried in Python 2 & 3
my_metaclass = TopLevelDocumentMetaclass my_metaclass = TopLevelDocumentMetaclass
@ -1069,7 +1066,6 @@ class DynamicEmbeddedDocument(six.with_metaclass(DocumentMetaclass, EmbeddedDocu
information about dynamic documents. information about dynamic documents.
""" """
# The __metaclass__ attribute is removed by 2to3 when running with Python3
# my_metaclass is defined so that metaclass can be queried in Python 2 & 3 # my_metaclass is defined so that metaclass can be queried in Python 2 & 3
my_metaclass = DocumentMetaclass my_metaclass = DocumentMetaclass