Pylint warn the usage of print statement - django

I am using pylint_django for my django project. And I want to disable print statement usage or warn about it at least. Because I am using custom logger class. But there is no any warn about usage of print.
extension-pkg-whitelist=
ignore=CVS
ignore-patterns=
jobs=1
limit-inference-results=100
load-plugins=
persistent=yes
suggestion-mode=yes
unsafe-load-any-extension=no
[MESSAGES CONTROL]
confidence=
disable=missing-docstring,
invalid-name,
astroid-error,
protected-access,
broad-except
enable=c-extension-no-member, print-statement
[REPORTS]
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
output-format=text
reports=no
score=yes
[REFACTORING]
max-nested-blocks=5
never-returning-functions=sys.exit
[LOGGING]
logging-format-style=old
logging-modules=logging
....
How can i solve this issue?
VsCode settings.json
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.linting.flake8Enabled": false,
"python.linting.prospectorEnabled": false,
"python.linting.pylintArgs": [
"--load-plugins=pylint_django",
"--rcfile=.pylintrc",
"--enable=print-statement"
]
}

You can do that using the deprecated checkers bad-functions options:
[tool.pylint]
bad-functions = ["map", "filter", "print"]

Related

place else on new line in Visual Studio Code

how can I place my else on new line, for example, I want to change
if () {
} else {
}
into
if() {
}
else {
}
I have edit theC_Cpp: Clang_format_fallback Style and entered { BasedOnStyle:Microsoft, IndentWidth: 4, ColumnLimit: 0}
Looks like vscode's formatter uses clang-format by default, so if you didn't change it, we can refer to the clang-format options directly, can you try to append the following key-value (BeforeElse) pair within your braces?
BraceWrapping: [BeforeElse: true]
If that doesn't work, then you should try to use the traditional .clang-format file which vscode also supports.

AWS Step Functions: Choice after Parallel Block

I'm executing a parallel block that has a list as an output, like this:
[
{
"Query": "SELECT * FROM some_table_1 WHERE my_partition = 20220101",
"PartitionValue": "20220101"
},
{
"Query": "SELECT * FROM some_table_2 WHERE my_partition = 20220101",
"PartitionValue": "20220101"
},
{
"Query": "SELECT * FROM some_table_3 WHERE my_partition = 20220102",
"PartitionValue": "20220102"
}
]
After the parallel block I have a Choice state with a rule that all the PartitionValue must be the same, else I end the execution with a error.
So I wrote something like this in my choice rule:
"$.[0].PartitionValue" == "$.[1].PartitionValue"
AND
"$.[0].PartitionValue" == "$.[2].PartitionValue"
AND
"$.[1].PartitionValue" == "$.[2].PartitionValue"
The thing is, when i'm trying to save the state machine it throws an error saying square brackets ']' are not valid characters.
I checked the documentation for something like "you can't access lists in choice states you st00pid' but did not find.
What am I doing wrong? Is there any other way I can achieve this validation step?

String array as argument in endpoint result in error code 10 in Mandos tests

The problem
Here's my function :
#[endpoint(registerItem)]
fn register_item(&self, items_id: &[String])
{
// nothing for the moment
}
In my Mandos tests, everything is good (setState, scDeploy, etc..) until I test the call of this endpoint like so :
{
"step": "scCall",
"tx": {
"from": "address:owner",
"to": "sc:equip",
"function": "registerItem",
"arguments": [
"0x70757461696e|0x70757461696e"
],
"gasLimit": "5,000,000",
"gasPrice": "0"
},
"expect": {
"status": "0",
"gas": "*",
"refund": "*"
}
}
When I run it, I got the error code 10 aka execution failed.
This is the entire log :
Output: Scenario: init.scen.json ... FAIL: result code mismatch. Tx . Want: 0. Have: 10 (execution failed). Message: execution failed
Done. Passed: 0. Failed: 1. Skipped: 0.
ERROR: some tests failed
** Things I have tried **
I have replaced the strings array with an int array and I didn't get this problem. I also tried [str] but I got this error :
15 | #[elrond_wasm::derive::contract]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
If it's a endpoint I think you have to use SDK special type for that like ManagedVec so that Node can know how to serialize/deserialize it.
So maybe try this :
#[endpoint(registerItem)]
fn register_item(&self, items_id: ManagedVec<ManagedBuffer>)
{
// nothing for the moment
}

Python MongoDB ReferenceError: weakly-referenced object no longer exists

I am an error ReferenceError: weakly-referenced object no longer exists in my code, I have tried to debug it that I don't know why am I getting this.
I am using mongodb and python 3.6.10
here is my code, please help
a = 't1'
b = ['v1', 'v2', 'v3']
services = dict()
for value in b:
record = MyModel.objects.filter(myid=id, a=a, value=value).first()
keys = record['services'].keys()
for key in keys:
key_value = record['services'][key]
if key in services:
services[key].extend(key_value) # Getiing error here in this line
else:
services.update({key: key_value})
print(services)
MyModel looks like
{
"myid" : "1",
"a" : "t1",
"b" : "v1",
"services" : {
"service_1" : [
{
"serviceid" : "1012",
"service_type" : "service_1"
}
]
}
{
"myid" : "1",
"a" : "t1",
"b" : "v2",
"services" : {
"service_2" : [
{
"serviceid" : "1013",
"service_type" : "service_2"
}
]
}
code works fine if there is only one value in b, but if code iterate the second time and tries to perform services[key].extend(key_value), code generates the error.
I don't think it is related to this code phrase. It can be caused by your db connector. You may try to close the connection without closing the cursor.
It generally happens when you use a destructor __del__ for a weak referenced object. When your destructor runs before the garbage collector, it throws that kind of exception. You can read more about weakref here.
after a lot of try and error, I have found that if I put values in empty list then code works fine so I have updated my code. I am still don't know why the above code is giving me an error, this is just an alternative to the above code.
Hope this will help someone facing the same problem.
a = 't1'
b = ['v1', 'v2', 'v3']
services = dict()
for value in b:
record = MyModel.objects.filter(myid=id, a=a, value=value).first()
keys = record['services'].keys()
for key in keys:
key_value = record['services'][key]
if not key in services:
services[key] = list()
services[key].extend(key_value)
print(services)

How to generate and use the generated file

Is it possible, with ocp-build, to do the following actions:
Compile a generator.
Call the generator to generate a file.
Compile the project with the generated file.
So far, I tried this:
(generator.ocp)
begin library "error_gen"
sort = true
files = [ "error_gen.ml" ]
requires = [str]
end
(generated.ocp)
begin library "error_code"
sort = true
files = [
"error_code.ml" (
pp = [ "./_obuild/error_gen/error_gen.byte" ]
pp_requires = [ "error_gen:byte" ]
)
]
requires = ["error_gen"]
end
(and the main.ocp)
begin program "main"
sort = true
files = []
requires = ["error_code" "parser"]
end
It complains with this message:
Error: in project "error_code", the source filename
"src/generated/error_code.ml" does not exist
I saw that some supports exist for version file generation, such as in the project ocp-indent
line 46.
"indentVersion.ml" (ocp2ml) (* auto-generated by ocp-build *)
Any helps greatly appreciated, thanks.
In branch "next" of github.com/OCamlPro/ocp-build, you will find a version of ocp-build that might solve your issue:
begin library "error_code"
sort = true
files = [ "error_code.ml" ]
build_rules = [
"error_code.ml" (
(* the files that are needed to call the command *)
sources = [ "%{error_gen_FULL_DST_DIR}%/error_gen.byte" ]
(* the commands to be executed, in the sub-directory of the library
each command has the syntax: { "COMMAND" "ARG1" "ARG2" ... }
*)
commands = [
{ "%{error_gen_FULL_DST_DIR}%/error_gen.byte" }
]
)
]
requires = ["error_gen"]
end
This is, for example, used in wxOCaml:
https://github.com/OCamlPro/ocplib-wxOCaml/blob/next-ocpbuild/configure.ocp
Commands can be post-fixed with options:
{ "configure" } (chdir = "subdirectory") (* to execute in a sub-directory *)
{ "cat" "toto" } (stdout = "new_toto") (* to copy the stdout in "new_toto" *)