pylint incorrectly identifies constant name as C0103 not conforming to const-rgx expression - regex

I've been linting my python code for some time now in order to make it more Pythonian and to that effect I've been using pylint to help identify problematic code blocks. However, now I'm having a kind of weird error, where pylint is flagging a correctly formatted constant name as not conforming to the regex provided.
Orginially, the constant was named main, which should match with the regex [a-z\_][a-z0-9\_]{2,30}$, but I got the convention violation message anyway. I tried changing the constant to run_main without any change. I even tried chaning the regex to [\_][a-z0-9\_]{2,30}$|[a-z][\_][a-z0-9\_]{2,30}$but the convention violation persists. I've tried testing the expressions on several regex testing sites to make sure I was not in the wrong. Is it a bug in pylint or am I missing something obvious?
The constant is defined in the following code block:
if __name__ == "__main__":
javabridge.start_vm(class_path=bf.JARS)
run_main = mainInterface()
and the relevant part of my pylintrc file is:
# Naming style matching correct constant names
#const-naming-style=
# Regular expression matching correct constant names. Overrides const-naming-
# style
const-rgx='[\_][a-z0-9\_]{2,30}$|[a-z][\_][a-z0-9\_]{2,30}$'
which yields the following output:
393,4,convention,C0103:Constant name "run_main" doesn't conform to "'[\\_]
[a-z0-9\\_]{2,30}$|[a-z][\\_][a-z0-9\\_]{2,30}$'" pattern ("'[\\_][a-z0-
9\\_]{2,30}$|[a-z][\\_][a-z0-9\\_]{2,30}$'" pattern)

Pylint wants any variable assigned in the outermost scope to be in all uppercase. Calling it MAIN should remove the warning.

Related

OpenModelica SimulationOptions 'variableFilter' not working with '^' exceptions

To reduce size of my simulation output files, I want to give variable name exceptions instead of a list of many certain variables to the simulationsOptions/outputFilter (cf. OpenModelica Users Guide / Output) of my model. I found the regexp operator "^" to fullfill my needs, but that didn't work as expected. So I think that something is wrong with the interpretation of connected character strings when negated.
Example:
When I have any derivatives der(...) in my model and use variableFilter=der.* the output file will contain all the filtered derivatives. Since there are no other varibles beginning with character d the same happens with variableFilter=d.*. For testing I also tried variableFilter=rde.* to confirm that every variable is filtered.
When I now try to except by variableFilter=^der.*, =^rde.* or =^d.*, I get exactly the same result as without using ^. So the operator seems to be ignored in this notation.
When I otherwise use variableFilter=[^der].*, =[^rde].* or even =[^d].*, all wanted derivation variables are filtered from the ouput, but there is no difference between those three expressions above. For me it seems that every character is interpretated standalone and not as as a connected string.
Did I understand and use the regexp usage right or could this be a code bug?
Side/follow-up question: Where can I officially report this for software revision?
_
OpenModelica v.1.19.2 (64-bit)

data flux dqmatch function error df_error_invalid_input

I am getting error while running program in SAS, for example, DQmatch function .
DQMATCH('India Mumbai rod no2',address text,80,'ENIND')
For other matching definition, it's working fine but I am getting error only for this definition.
I don't know whether to add this as a comment or an answer. I don't use the dqmatch function but the documentation and other usage examples I've seen indicate that the second argument should be a quoted literal. If it does not need to be a quoted literal then verify if you're allowed a space in the argument you've supplied.
If none of this helps then I suggest you add the full error message you are getting (if there is any more) and an example of a call to dqmatch that is working.

Is a ValueList() a string?

I am trying to convert the results of a query into an array
this.arLibrary = ValueList(qryLibrary.ID).ListToArray();
And I get the following error
Detail A script statement must end with ";".The CFML compiler was
processing:A script statement beginning with
this.arLibrary on line 43, column 9.A cfscript tag
beginning on line 21, column 2. KnownColumn -1 KnownLine -1
KnownText <unknown> Line 43 Message Invalid construct.
Snippet this.arLibrary =
ValueList(qryLibrary.ID).
StackTrace
This does work
temp = ValueList(qryLibrary.ID);
this.arMetricLibActive = temp.ListToArray();
It makes me wonder if ValueList() is a string
Yes, it's a string. The error is a parsing issue in the CFML engine. The same syntax works fine in Lucee. File a bug like Henry suggested.
Here's an example in the CommandBox REPL
CFSCRIPT-REPL: foo = queryNew('bar')
{
"COLUMNS":[
"BAR"
],
"DATA":[
]
}
CFSCRIPT-REPL: valueList( foo.bar ).listToArray()
[
]
James, it'd be useful if you read error messages when they are presented to you: they generally contain pertinent information. I don't mean this in a "stating the obvious" sort of way, but rather that it's actually a very important part of troubleshooting problems. You are faced with an error message from the compiler, which means the error occurred when the source code was being compiled. However you are asking a question about data types, which - in a loosely and dynamically typed language like CFML - is a runtime consideration. "Runtime" implies "when the code is being run" which is intrinsically after the code is compiled. If the code can't compile: it won't be run.
So the issue is not whether valueList() returns a string or anything like that.
The issue here is that there is a bug in ColdFusion's CFML parser, and it is not able to interpret this expression:
ValueList(qryLibrary.ID).ListToArray()
I don't know why there's a problem with this: there should be no problem with parsing the calling of a method on another function call's return value; and indeed it seems to be a peculiarity of using valueList() like this, as opposed to built-in functions in general.
File a bug.
As for what to do about it in your code in the meantime, I think Dan is right: generally one can use a query column as an array anyhow, provided one uses bracket notation to reference the column, eg: qryLibrary["ID"]. Brad draws attention to this not working on Lucee, but... this is neither here nor there, and just something that Lucee needs to deal with. There was a bug raised for this in Railo - https://issues.jboss.org/browse/RAILO-641 - but they declined to address it, with only semi-valid reasoning.
Epilog:
This works on ColdFusion 2016 and above
<cfscript>
qryLibrary = QueryNew("ID", "varchar");
qryLibrary.addrow({"id" : "cat"});
qryLibrary.addrow({"id" : "dog"});
qryLibrary.addrow({"id" : "fish"});
writedump(qryLibrary);
arLibrary = ValueList(qryLibrary.ID).ListToArray();
writedump(arLibrary);
</cfscript>
https://cffiddle.org/app/file?filepath=6588296c-5e4d-49a4-894b-4986513e9e30/0ecde857-6d28-4e43-88a7-7830c109ab11/84cd7e81-16f8-43d7-b4c9-5490b1b5d007.cfm

Log parsing rules in Jenkins

I'm using Jenkins log parser plugin to extract and display the build log.
The rule file looks like,
# Compiler Error
error /(?i) error:/
# Compiler Warning
warning /(?i) warning:/
Everything works fine but for some reasons, at the end of "Parsed Output Console", I see this message,
NOTE: Some bad parsing rules have been found:
Bad parsing rule: , Error:1
Bad parsing rule: , Error:1
This, I'm sure is a trivial issue but not able to figure it out at this moment.
Please help :)
EDIT:
Based on Kobi's answer and having looked into the "Parsing rules files", I fixed it this way (a single space after colon). This worked perfectly as expected.
# Compiler Error
error /(?i)error: /
# Compiler Warning
warning /(?i)warning: /
The Log Parser Plugin does not support spaces in your pattern.
This can be clearly seen in their source code:
final String ruleParts[] = parsingRule.split("\\s");
String regexp = ruleParts[1];
They should probably have used .split("\\s", 2).
As an alternative, you can use \s, \b, or an escape sequence - \u0020.
I had tried no spaces in the pattern, but that did not work.
Turns out that the Parsing Rules files does not support
empty lines in it. Once I removed the empty lines, I did not
get this "Bad parsing rule: , Error:1".
I think since the line is empty - it doesn't echo any rule after
the first colon. Would have been nice it the line number was
reported where the problem is.

Django regular expression confusion involving unicode

We're trying to use BeautifulSoup through Django to do some text extraction. We've got an odd bug that we've traced down to the following that we don't understand.
If we issue the following in a standard Python prompt:
import re
print re.match("&#([0-9]+)[^0-9]","»")
We get an output of None, as should be expected. However, when we put this code in sgmllib.py (which Django eventually calls through a long string of calls via our website), Python does successfully match this, and returns an object. It's appearing to us as though Django is somehow ignoring the x in the above string. I assume this has got to be related to unicode settings, and so on, but we can't seem to figure out why Django is running differently as opposed to when we run this code ourselves in a vanilla Python 2.6 session.
Why should the regular expression above not match when run normally, but does match, when Django tries it?
The 'x' is part of the string you are testing. If you don't account for it in your regular expression then it won't match. Python is working correctly. I would be surprised if Django behaves differently, but maybe there is a bug somewhere else. If adding the 'x' gives you problems in Django, you can try this:
>>> rc = re.match("&#[xX]?([0-9]+)","»")
>>> rc.group(1)
'00'