[Python-projects] Is Pylint check variables outside of functions?
Pierre Rouleau
prouleau001 at sympatico.ca
Sun May 7 16:11:49 CEST 2006
Sylvain Thénault wrote:
> On Sunday 07 May à 00:41, Sylvain Thénault wrote:
>
>>On Friday 28 April à 09:32, Pierre_Rouleau at ImpathNetworks.com wrote:
>>
>>>Bonjour Sylvain,
>
>
> Bonjour Pierre,
>
>
>>>Is Pylint (the latest) supposed to report that invalid names of variables
>>>declared outside functions ? I just noticed that it was not reporting variable
>>>names that did not comply with ('variable-rgx', 'inlinevar-rgx', 'good-names')
>>>specs when those variables are outside of functions/method/class definitions
>>>like code that would appear after the "if __name__ == "_main__": " clause.
>>
>>that's a bug, I've added it to our tracker.
>
>
> hum, I've actually took a deeper look at this and I don't have the same
> results as you have. Pylint is checking module level variables since
> version 0.10, and those variables should should be consistent with the
> const-rgx pattern, which default to ([A-Z_][A-Z1-9_]*)|(__.*__))$.
> Running pylint on your sample code, I get :
>
> C: 25: Invalid name "x" (should match (([A-Z_][A-Z1-9_]*)|(__.*__))$)
> C: 29: Invalid name "a" (should match (([A-Z_][A-Z1-9_]*)|(__.*__))$)
> C: 30: Invalid name "b" (should match (([A-Z_][A-Z1-9_]*)|(__.*__))$)
> C: 37:print_j: Invalid name "y" (should match [a-z_][a-z0-9_]{2,30}$)
> C: 41:print_j: Invalid name "c" (should match [a-z_][a-z0-9_]{2,30}$)
> C: 42:print_j: Invalid name "d" (should match [a-z_][a-z0-9_]{2,30}$)
> C: 53:Test.__init__: Invalid name "z" (should match
> [a-z_][a-z0-9_]{2,30}$)
> C: 58:Test.show: Invalid name "g" (should match [a-z_][a-z0-9_]{2,30}$)
> C: 65:Test.showu: Invalid name "u" (should match [a-z_][a-z0-9_]{2,30}$)
> C: 68:Test.showu: Invalid name "g" (should match [a-z_][a-z0-9_]{2,30}$)
> C: 77: Invalid name "h" (should match (([A-Z_][A-Z1-9_]*)|(__.*__))$)
> C: 78: Invalid name "t" (should match (([A-Z_][A-Z1-9_]*)|(__.*__))$)
> C: 79: Invalid name "n" (should match (([A-Z_][A-Z1-9_]*)|(__.*__))$)
>
You are correct, I was just reporting a false alarm. I forgot
const-rgx. I had modified const-rgx and I made a mistake in the regexp
for it. Therefore pylint is reporting things properly.
Sorry for the invalid report.
--
Pierre Rouleau
More information about the Python-Projects
mailing list