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

E0308: bytes not recognized after encode #3599

Closed
bitozoid opened this issue May 6, 2020 · 0 comments · Fixed by pylint-dev/astroid#807
Closed

E0308: bytes not recognized after encode #3599

bitozoid opened this issue May 6, 2020 · 0 comments · Fixed by pylint-dev/astroid#807
Assignees
Labels

Comments

@bitozoid
Copy link

bitozoid commented May 6, 2020

Steps to reproduce

  1. File test_bytes.py
class Sample:

    # warns about E0308: invalid-bytes-returned
    def __bytes__(self):
        return "hey".encode('utf-8')


# will print <class 'bytes'>
print(type(bytes(Sample())))
  1. pylint it.
$ python test_bytes.py
<class 'bytes'>

$ pylint test_bytes.py
************* Module test_bytes
test_bytes.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test_bytes.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test_bytes.py:1:0: C0115: Missing class docstring (missing-class-docstring)
test_bytes.py:4:4: E0308: __bytes__ does not return bytes (invalid-bytes-returned)
test_bytes.py:1:0: R0903: Too few public methods (1/2) (too-few-public-methods)

-------------------------------------
Your code has been rated at -10.00/10                                    

Current behavior

I get an E0308.

Expected behavior

Not to get an E03008.

pylint --version output

pylint 2.5.2
astroid 2.4.1
Python 3.7.7 (default, Mar 23 2020, 11:12:08) 
[GCC 9.3.0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants