From bc3f2793202885ff86b740b66de26fa68f9eb4e6 Mon Sep 17 00:00:00 2001 From: Adi Roiban Date: Fri, 12 Jun 2015 13:44:01 +0100 Subject: [PATCH 1/2] Revert "Revert "`__version__` is not a violation of the Twisted naming convention"" This reverts commit f57e00013a11127df357c4a1280c68f40e22fb29. --- twistedchecker/configuration/pylintrc | 2 +- ...{attributename_pass.py => attributename.py} | 13 +++++++++++++ .../functionaltests/attributename.result | 6 ++++++ .../functionaltests/attributename_fail.py | 18 ------------------ .../functionaltests/attributename_fail.result | 3 --- .../functionaltests/attributename_pass.result | 0 6 files changed, 20 insertions(+), 22 deletions(-) rename twistedchecker/functionaltests/{attributename_pass.py => attributename.py} (62%) create mode 100644 twistedchecker/functionaltests/attributename.result delete mode 100644 twistedchecker/functionaltests/attributename_fail.py delete mode 100644 twistedchecker/functionaltests/attributename_fail.result delete mode 100644 twistedchecker/functionaltests/attributename_pass.result diff --git a/twistedchecker/configuration/pylintrc b/twistedchecker/configuration/pylintrc index 70f03b2..c1801cb 100644 --- a/twistedchecker/configuration/pylintrc +++ b/twistedchecker/configuration/pylintrc @@ -63,7 +63,7 @@ function-rgx=((([a-z])|([a-z]+_[a-z]))[a-zA-Z0-9]+)$|(__[a-z]+__)$|(\_.+)$|(test # Attribute names should be in mixed case, with the first letter lower case, # each word separated by having its first letter capitalized just like method names. # And all private names should begin with an underscore. -attr-rgx=(((([a-z_])|([a-z]+_[a-z]))[a-zA-Z0-9]+)|(([A-Z_][A-Z0-9_]*)))$ +attr-rgx=(((([a-z_])|([a-z]+_[a-z])|(__))[a-zA-Z0-9]+|(__))|(([A-Z_][A-Z0-9_]*)))$ # Classes are to be named in mixed case, with the first letter capitalized, # each word separated by having its first letter capitalized. diff --git a/twistedchecker/functionaltests/attributename_pass.py b/twistedchecker/functionaltests/attributename.py similarity index 62% rename from twistedchecker/functionaltests/attributename_pass.py rename to twistedchecker/functionaltests/attributename.py index 2c0fa3e..bebd55d 100644 --- a/twistedchecker/functionaltests/attributename_pass.py +++ b/twistedchecker/functionaltests/attributename.py @@ -13,8 +13,21 @@ def __init__(self): """ A init of this class """ + # Bad names. + self.foo_bar_zar = None + self.FooBarZar = None + self.a = None + self._fooBar_ = None + self._fooBar__ = None + self.__fooBar_ = None + + # Good names. self.fooBarZar = None self._fooBarZar = None self.foobar = None + self.__foobar__ = None + self.__fooBar__ = None + self.__dict__ = {} + self.__version__ = {} # In some cases constants are lazy initialized as instance members. self.FOOBARZAR = None diff --git a/twistedchecker/functionaltests/attributename.result b/twistedchecker/functionaltests/attributename.result new file mode 100644 index 0000000..5e57e32 --- /dev/null +++ b/twistedchecker/functionaltests/attributename.result @@ -0,0 +1,6 @@ +20:C0103 +21:C0103 +23:C0103 +18:C0103 +17:C0103 +19:C0103 diff --git a/twistedchecker/functionaltests/attributename_fail.py b/twistedchecker/functionaltests/attributename_fail.py deleted file mode 100644 index 30016eb..0000000 --- a/twistedchecker/functionaltests/attributename_fail.py +++ /dev/null @@ -1,18 +0,0 @@ -# enable: C0103 - -class FooClass: - """ - Attribute names should be in mixed case, - with the first letter lower case, - each word separated by having its first letter capitalized - just like method names. - And all private names should begin with an underscore. - """ - - def __init__(self): - """ - A init of this class - """ - self.foo_bar_zar = None - self.FooBarZar = None - self.a = None diff --git a/twistedchecker/functionaltests/attributename_fail.result b/twistedchecker/functionaltests/attributename_fail.result deleted file mode 100644 index f64efab..0000000 --- a/twistedchecker/functionaltests/attributename_fail.result +++ /dev/null @@ -1,3 +0,0 @@ -18:C0103 -16:C0103 -17:C0103 diff --git a/twistedchecker/functionaltests/attributename_pass.result b/twistedchecker/functionaltests/attributename_pass.result deleted file mode 100644 index e69de29..0000000 From 151d7bf7b309272a96ad1f1dc0f165ad967f57bf Mon Sep 17 00:00:00 2001 From: Adi Roiban Date: Fri, 12 Jun 2015 13:56:09 +0100 Subject: [PATCH 2/2] Update examples for reserved variable names. --- twistedchecker/configuration/pylintrc | 2 +- twistedchecker/functionaltests/attributename.py | 5 +++++ twistedchecker/functionaltests/attributename.result | 8 +++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/twistedchecker/configuration/pylintrc b/twistedchecker/configuration/pylintrc index c1801cb..5f81c4d 100644 --- a/twistedchecker/configuration/pylintrc +++ b/twistedchecker/configuration/pylintrc @@ -63,7 +63,7 @@ function-rgx=((([a-z])|([a-z]+_[a-z]))[a-zA-Z0-9]+)$|(__[a-z]+__)$|(\_.+)$|(test # Attribute names should be in mixed case, with the first letter lower case, # each word separated by having its first letter capitalized just like method names. # And all private names should begin with an underscore. -attr-rgx=(((([a-z_])|([a-z]+_[a-z])|(__))[a-zA-Z0-9]+|(__))|(([A-Z_][A-Z0-9_]*)))$ +attr-rgx=(((([a-z_])|([a-z]+_[a-z]))[a-zA-Z0-9]+)|(([A-Z_][A-Z0-9_]*))|(__[a-zA-Z0-9][a-zA-Z0-9_]*[a-zA-Z0-9]+__)|(__[a-zA-Z0-9]__))$ # Classes are to be named in mixed case, with the first letter capitalized, # each word separated by having its first letter capitalized. diff --git a/twistedchecker/functionaltests/attributename.py b/twistedchecker/functionaltests/attributename.py index bebd55d..e26794e 100644 --- a/twistedchecker/functionaltests/attributename.py +++ b/twistedchecker/functionaltests/attributename.py @@ -20,14 +20,19 @@ def __init__(self): self._fooBar_ = None self._fooBar__ = None self.__fooBar_ = None + self.___longStart__ = None + self.__longEnd___ = None # Good names. self.fooBarZar = None self._fooBarZar = None self.foobar = None + # Any __*__ name is accepted. self.__foobar__ = None self.__fooBar__ = None + self.__foo_bar__ = None self.__dict__ = {} self.__version__ = {} + self.__a__ = {} # In some cases constants are lazy initialized as instance members. self.FOOBARZAR = None diff --git a/twistedchecker/functionaltests/attributename.result b/twistedchecker/functionaltests/attributename.result index 5e57e32..6e4b434 100644 --- a/twistedchecker/functionaltests/attributename.result +++ b/twistedchecker/functionaltests/attributename.result @@ -1,6 +1,8 @@ +19:C0103 +24:C0103 20:C0103 -21:C0103 +22:C0103 23:C0103 -18:C0103 17:C0103 -19:C0103 +18:C0103 +21:C0103