Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix codacy warnings #271

Open
moy opened this issue Feb 28, 2019 · 2 comments
Open

Fix codacy warnings #271

moy opened this issue Feb 28, 2019 · 2 comments
Labels
easy? Probably easy to implement, or WIP almost complete

Comments

@moy
Copy link
Collaborator

moy commented Feb 28, 2019

I've activated codacy for MechanicalSoup.

There seem to be some relevant warnings here:

https://app.codacy.com/app/moy/MechanicalSoup/issues/index

(at least the value={...})

Some can't be fixed without breaking backward compatibility, but there should be a clean way to disable them (I didn't investigate, and I had never used Codacy before).

Cc: @senabIsShort, @QuentinSanchez, @MartinDlry, this may be an interesting topic to work on: reading and fixing warnings is a nice way to learn the subtleties of a language.

@moy moy added the easy? Probably easy to implement, or WIP almost complete label Feb 28, 2019
@hemberger
Copy link
Contributor

When I visit that link, it says there are no issues. There are 3 "use of exec" ignored issues. Perhaps they updated their software and fixed some false positives?

By the way, I have found ScrutinizerCI to be a lot more useful than Codacy in other projects.

@moy
Copy link
Collaborator Author

moy commented Apr 1, 2019

Yes, I'm not sure whether they updated their software or I changed something, but I don't see the error anymore.

In the config, I still have the check active, though. The doc at Codacy says:

Explanation

Used when a mutable value as list or dictionary is detected in a default value for an argument.

This is the message that inspired the creation of the PyLint Messages wiki in the first place!!

Ex:

def my_method(self, arg1, extras=[]):
    // blah blah...

To a Python novice, this may seem like a reasonable way to default to an empty array for the extras param. What really happens is that this "default" array gets created as a persistent object, and every invocation of my_method that doesn't specify an extras param will be using that same list object—any changes to it will persist and be carried to every other invocation!

See Ned Batchelder's blog post of 14 June 2008 about PyLint, which highlights this problem and suggests some better alternatives.

Source: http://pylint-messages.wikidot.com/messages:w0102

(I'm tempted to think that Codacy is actually broken now and was working properly before)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy? Probably easy to implement, or WIP almost complete
Projects
None yet
Development

No branches or pull requests

2 participants