Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

sometimes I need to implement a method with underscores in its name #76

Open
glyph opened this issue Apr 23, 2014 · 5 comments
Open

sometimes I need to implement a method with underscores in its name #76

glyph opened this issue Apr 23, 2014 · 5 comments

Comments

@glyph
Copy link
Member

glyph commented Apr 23, 2014

Especially when writing test fakes for 3rd-party code like pyOpenSSL, I need to type _ in an identifier in a place twistedchecker doesn't like it. We should have a way to quash this warning, at least.

@adiroiban
Copy link
Member

Maybe we can relax this rule in files from the test suite.

I prefer this generic exception, rather than having to add an ignore markup each time the exception is break.

@glyph
Copy link
Member Author

glyph commented Sep 30, 2014

I agree that a generic exception would be better. I suppose we could start by relaxing it in test modules and see how many spurious failures remain...

@glyph
Copy link
Member Author

glyph commented Dec 1, 2014

Related: #82 #77

Also, __qualname__.

Hit this on http://twistedmatrix.com/trac/ticket/4804

@adiroiban
Copy link
Member

#82 #77 are for attribute names ... not for methods

Can you please provide an example code which fails?

I tried the following code on master and it does not complain about get_context() method

class InMemoryOpenSSLStuff(object):
    """
    Test helpers implementing / faking external interfaces are excepted
    from Twisted coding standard
    """

    def get_context(self):
        """
        Some docs.
        """

@adiroiban
Copy link
Member

Right now it rejects

def global_tcpip_forward

but this is accepted

global_tcpipForward

For the case when pyOpenSSL mocks are implemented, I would say that they can be muted using something like # pylint: disable=C0103


For the global_tcpip_forward we have add some hints to the code so that the linter will know how to handle these methods.

    @protocolDispatcher('global')
    def gotGlobalRequest(self, requestType, data):
        # XXX should this use method dispatch?
        requestType = requestType.replace('-', '_')
        f = getattr(self, "global_%s" % requestType, None)
        if not f:
            return 0
        return f(data)

the decorator could set up a _protocolDispatchers = ['global'] variable and the the linter can check that methods starting with this can have underlines.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants