Skip to content

Python3 compatibility #38

Open
Open

Description

@eamanu

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

Activity

  1. matiasdemarchi commented on Jun 27, 2021

    @matiasdemarchi
    Collaborator

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

  2. matiasdemarchi commented on Jul 2, 2021

    @matiasdemarchi
    Collaborator

    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.

  3. eamanu commented on Jul 3, 2021

    @eamanu
    CollaboratorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions