Is there any way to automatically fix 'invalid-envar-default' pylint issue?
None of the tools that I tried (autopep8, autoflake and black) do not automatically fix this issue.
The solution seems to be pretty straightforward for all cases, ensuring the second parameter is a string (it could be just wrap it with str():
Going from:
os.getenv('SECRET_KEY', 1) # [invalid-envvar-default]
to: os.getenv('SECRET_KEY', '1')
pylint does not have autofix at the moment. ruff aim to do that, but has few lints available at the moment (and not 'invalid-envar-default'). It's likely that this kind of check will be dropped from pylint or not implemented in ruff because it's really really close to what a type checker should do generically applied on a single parameter of a single function. It feel like a remnant of time when type checker where not available. (source: I'm a pylint maintainer and I'm thinking about removing this check outright).
So to sump up, the optimal way to fix this right now is manually.
Related
When I use .toMatchSnapshot() if one matcher fails they are all highlighted in the diff making it hard to debug a test with multiple matchers. Passing assymmetric matchers are not supposed to be highlighted anymore according to https://github.com/facebook/jest/pull/9257.
When I use my debugger it looks like the code never makes it to the printDiffOrStringify from .toMatchSnapshot(). It uses other methods instead to print the diff.
Interested to hear if anyone else has dealt with this issue before I open a bug. Maybe I'm missing something. In the PR it sounds like this was solved generally for all expect functions.
I've taken over a deploy process and part of this runs Cargo Clippy which was working fine up until late last week, when I started getting this error:
error: Question mark operator is useless here
I've read the suggested link https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark
and understand that the ? is no longer required, and have had a look at the suggested changes it offers. I just want to know whether it is okay for me to make the changes as suggested, as some seem to remove some code so I'm not sure whether the result will be the same.
Some of the suggested changes seem to be simple and okay:
From this
Ok(dsl::orgs
.filter(dsl::salesforce_id.eq(salesforce_id))
.get_result(conn)?)
To this:
dsl::orgs
.filter(dsl::salesforce_id.eq(salesforce_id))
.get_result(conn)
So I'm guessing that the above type of change is safe to accept?
Then I have these
Here the 'optional' has disappeared in the suggested fix. From:
Ok(dsl::orgs
.filter(
dsl::customer_id
.eq(new_org.customer_id)
.and(dsl::name.eq(&new_org.name)),
)
.get_result(conn)
.optional()?)
To
dsl::orgs
.filter(
dsl::customer_id
.eq(new_org.customer_id)
.and(dsl::name.eq(&new_org.name)),
)
And this one, where the inner join has disappeared in the suggested fix:
Ok(orgs::dsl::orgs
.filter(orgs::dsl::customer_id.eq(customer_id))
.filter(orgs::dsl::kind.eq(org_kind))
.filter(
orgs::dsl::kind
.eq(OrgKind::Production)
.or(orgs::dsl::name.eq(&org_name)),
)
.inner_join(schema::customers::dsl::customers)
.get_result(conn)?)
to this:
orgs::dsl::orgs
.filter(orgs::dsl::customer_id.eq(customer_id))
.filter(orgs::dsl::kind.eq(org_kind))
.filter(
orgs::dsl::kind
.eq(OrgKind::Production)
Are these 2 suggested fixes okay to implement? Could someone please provide some help?
I've taken over a deploy process and part of this runs Cargo Clippy which was working fine up until late last week,
The lint appeared last week because Rust 1.51 and a new accompanying Clippy version was released last Thursday, and it added needless_question_mark.
when I started getting this error:
Your CI should probably not consider all Clippy lints to be errors. Clippy is designed to give warnings about many things that are simply code style improvements, or possible problems; counting them as errors will lead to unnecessary breakage in the future.
So I'm guessing that the above type of change is safe to accept?
Ok(some_expression?) is almost the same as some_expression. The only difference is that the version with ? may implicitly convert the error type of the expression (the E in Result<T, E>) to the error type expected by the function. If the error types are the same and no conversion is required, then you can remove the Ok and ? and get the same results; if the error types are different, the simplified version will not compile.
Here the 'optional' has disappeared in the suggested fix.
This seems like a bug in Clippy or whatever tool is applying the fix, as the resulting code is semantically different and would not even compile. I'd remove the Ok and ? manually in that case, and report the bug.
While improving clippy lints, I was asked if it's possible to tell if a lint's suggestion can be spliced into the code directly ("change X to Y"), or if it is incomplete / informal and should be implemented manually ("consider renaming this variable").
Currently, clippy uses span_suggestion(Span, &str), but I don't see a way to inform the compiler about the type of suggestion being made. Is there some (planned) API to do this?
I already refresh DB!
The example can be work.
My problem is IntelliSense is work on line 5, 6
But at the line 7, tree(parameter) can't not find the method xpath()
IntelliSense is not work on line 7, why?
I try to find the answer, someone say need to Removing project __init__.py can fix the problem.
Where is the __init__.py ?
And there exists other good method to solve problem? like: update VS2013?
This is actually just a limitation of PTVS. To figure out the type of tree, it needs to figure out what etree.parse will return when passed a StringIO and HTMLParser. Depending on the code in parse, this may be near impossible to do without actually executing it.
If you hover over tree, I suspect you'll see that it is an unknown type. To force it to have a certain type, you can write:
assert isinstance(tree, WhateverType)
This will let PTVS know that it will definitely be of that type, though at runtime your program will crash if you are wrong. When support for type hints is added, you will be able to use those instead (but that will likely require updating to the very latest version of Visual Studio).
My program has a very specific error that took me a while to track down - now I don't know how to fix it. My code is very long and in many files and I don't see much point in posting it here.
In the IDE, everything runs fine, in both Debug and Release (with the runtime library set to either /MTd or /MT, respectively, so I'm assuming all dependencies are included).
However, when I run the standalone, I get a crash. At first I thought it was a dependency problem but it doesn't seem so.
At some point in the code, I am accessing a vector via a method call: t->GetList(), where GetList is defined as std::vector<T*> & GetList() and the method simply returns a member variable (simply defined as std::vector<T*> field in the class).
It turns out, if I print out the size of the list while running from the IDE, I get 0 (which is the correct answer in this case).
However, when doing the same thing running from standalone, I get the size as 467467353.
I tried changing the method declaration to std::vector<T*> * GetList() and doing return &field; and updating the rest of the code but this didn't fix anything.
I then tried replacing the member variable field with a pointer, and in the constructor instantiating a new vector and deleting it in the destructor. Still no luck.
So I made a simple test case program that simply made a class with a vector field, and a method to return a reference to it. Then in main I would create an instance variable and getting the vector and printing the size. This worked both in VC++ and as a standalone - both returned zero.
This is driving me nuts and I can't figure out why I'm getting different behaviour. Why is the standalone running differently, and what should I be looking at to fix this?
Thanks
Okay so it was literally a bug in my code that was very well hidden. I was dynamically casting to a wrong type.
Somehow it slipped past when I was running on Windows and OSX in both Debug and Release, and as a standalone on OSX. Good thing I found it.