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

Python3 compatibility #38

Open
eamanu opened this issue Jun 27, 2021 · 3 comments
Open

Python3 compatibility #38

eamanu opened this issue Jun 27, 2021 · 3 comments

Comments

@eamanu
Copy link
Collaborator

eamanu commented Jun 27, 2021

After a quick search in the code using the next flake8 command: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics I didn't follow any python3 issue. So, in my opinion openlex might be compatible with py3.

BTW I follow the next issues:

➜  OpenLex git:(master) flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | grep F632 
./modules/html2text.py:181:12: F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)
./modules/html2text.py:181:29: F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)
./modules/html2text.py:182:20: F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)
3     F632 use ==/!= to compare constant literals (str, bytes, int, float, tuple)

And

➜  OpenLex git:(master) flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | grep E999
./documents/pyDoctor.py:46:15: E999 SyntaxError: invalid syntax
1     E999 SyntaxError: invalid syntax

@matiasdemarchi can you fixed it?

cc: @marian-vignau

@matiasdemarchi
Copy link
Collaborator

Yes, I think i can fix it. Thanks for the suggestion!

@matiasdemarchi
Copy link
Collaborator

matiasdemarchi commented Jul 2, 2021

In the case of the Aaron Swartz's program html2text.py, the issue that your command is pointing to, has the following lines:

def onlywhite(line):
"""Return true if the line does only consist of whitespace characters."""
for c in line:
if c is not ' ' and c is not ' ':
return c is ' '
return line

My question is: "is not" and "is", are the same thing that == and != in Python 3? In that case, I wouldn't need to change it.

@eamanu
Copy link
Collaborator Author

eamanu commented Jul 3, 2021

They aren't the same.

The is operator will return True if the variable is pointing to the same object
And == will compare the value itself.

for instance (I'm on py3.9), using is:

>>> a = "hello world"
>>> a is "hello world"
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
False
>>> 

But if we compare the value equality,

>>> a == "hello world"
True
>>> 

Looking on upstream [0], that lines was not changed, so, I would like to hear the opinion of
@marian-vignau about what to do with this SyntaxWarning.


BTW: seems that exist a newer fork of html2text https://github.com/Alir3z4/html2text/

[0] https://github.com/aaronsw/html2text/blob/master/html2text.py#L92

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

No branches or pull requests

2 participants