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

Python 2: One syntax error and two undefined names / Python 3: Five undefined names #1617

Closed
cclauss opened this issue Nov 20, 2017 · 2 comments
Labels
compat Cross-platform and cross-Python compatibility examples Code examples in /examples tests New, missing or incorrect tests

Comments

@cclauss
Copy link

cclauss commented Nov 20, 2017

Python 2

See: https://travis-ci.org/explosion/spaCy/builds/304678969

python2 -m flake8 . --count --exclude=spacy/lang --select=E901,E999,F821,F822,F823 --show-source --statistics

./examples/information_extraction/entity_relations.py:39:18: E999 SyntaxError: invalid syntax
    for span in [*list(doc.ents), *list(doc.noun_chunks)]:
                 ^

./spacy/tests/lang/fr/test_lemmatization.py:25:14: F821 undefined name 'FR'
    tokens = FR("il y a des Costaricienne.")
             ^

./spacy/tests/regression/test_issue910.py:81:11: F821 undefined name 'Adam'
    sgd = Adam(nlp.entity.model[0].ops, 0.001)
          ^

1     E999 SyntaxError: invalid syntax
2     F821 undefined name 'FR'
3

Python 3

See: https://travis-ci.org/explosion/spaCy/builds/304678969

flake8 . --count --exclude=spacy/lang --select=E901,E999,F821,F822,F823 --show-source --statistics

./spacy/compat.py:56:16: F821 undefined name 'unicode'
    unicode_ = unicode
               ^

./spacy/compat.py:57:19: F821 undefined name 'basestring'
    basestring_ = basestring
                  ^

./spacy/compat.py:58:14: F821 undefined name 'raw_input'
    input_ = raw_input
             ^

./spacy/tests/lang/fr/test_lemmatization.py:25:14: F821 undefined name 'FR'
    tokens = FR("il y a des Costaricienne.")
             ^

./spacy/tests/regression/test_issue910.py:81:11: F821 undefined name 'Adam'
    sgd = Adam(nlp.entity.model[0].ops, 0.001)
          ^

5     F821 undefined name 'unicode'
@ines ines changed the title Python 3: Five undefined names Python 2: One syntax error and two undefined names / Python 3: Five undefined names Nov 20, 2017
@ines
Copy link
Member

ines commented Nov 20, 2017

Thanks a lot for the detailed report – I hope you don't mind that I merged the two issues, since they're essentially related to the same thing.

The spacy/compat.py errors should probably be excluded via # noqa: F821. Those are the Python 2/3-specific versions of the built-ins.

I'm surprised that the tests passed... will check, but I assume test_issue910.py is likely xfailed, and the French lemmatization tests require the models and are only run if --models --fr is set when running pytest (which we're not doing on Travis, as it's too time consuming and potentially flakey at the moment). Should be easy to fix by adding the FR fixture to the test arguments.

for span in [*list(doc.ents), *list(doc.noun_chunks)]:

Damn, this is a good catch. Looks like we only ever ran this example in Python 3, so will fix that to make it compatible.

@ines ines added examples Code examples in /examples tests New, missing or incorrect tests labels Nov 20, 2017
ines added a commit that referenced this issue Nov 20, 2017
@ines ines closed this as completed Dec 6, 2017
@ines ines added the compat Cross-platform and cross-Python compatibility label Dec 17, 2017
@lock
Copy link

lock bot commented May 8, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compat Cross-platform and cross-Python compatibility examples Code examples in /examples tests New, missing or incorrect tests
Projects
None yet
Development

No branches or pull requests

2 participants