Skip to content

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

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

2 participants

@glyph
Twisted Matrix Labs 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
Twisted Matrix Labs 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
Twisted Matrix Labs member
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
Twisted Matrix Labs member
glyph commented Dec 1, 2014

Related: #82 #77

Also, __qualname__.

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

@adiroiban
Twisted Matrix Labs 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
Twisted Matrix Labs 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.