Skip to content

Correct lint issues exposed with update to pylint-3#1652

Merged
mpharrigan merged 10 commits into
quantumlib:mainfrom
micpap25:pylintrc-fix
Jun 5, 2025
Merged

Correct lint issues exposed with update to pylint-3#1652
mpharrigan merged 10 commits into
quantumlib:mainfrom
micpap25:pylintrc-fix

Conversation

@micpap25
Copy link
Copy Markdown
Contributor

@micpap25 micpap25 commented May 28, 2025

Fixes #1440

Re-enables the following pylint issues which were disabled when bumping to pylint-3.

  • abstract-class-instantiated
  • deprecated-class
  • possibly-used-before-assignment
  • used-before-assignment

if np.sign(global_phase) == 1:
signs = '-' * num_ones + '+' * (9 - num_ones)
elif np.sign(global_phase) == -1:
else: # np.sign(global_phase) == -1:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we keep this as an elif and add an else clause that raises a ValueError or AssertionError?

@mpharrigan
Copy link
Copy Markdown
Collaborator

Can you revert the changes to remove the different types. The tooling should support us writing good code; we shouldn't let the tooling dictate worse patterns. Unless there's something I'm missing about the original pattern actually being wrong (??)

@micpap25
Copy link
Copy Markdown
Contributor Author

micpap25 commented Jun 3, 2025

@mpharrigan Pushed the reversion. My thought process is that the current state isn't good code since we are using abstraction purely for isinstance checks which seems convoluted and could be handled by one variable.

@mhucka mhucka added the unitaryhack Candidates for unitaryHACK 2025 label Jun 3, 2025
@mpharrigan
Copy link
Copy Markdown
Collaborator

The distinction shows up in calls to the constructor, with the unique class names helping to make the code more self-documenting.

Should we keep abstract-class-instantiated as a global skip? Am I correct in saying that they were all false-positives? And that now any time someone uses one of these classes they would have to add an additional "skip" comment?

@micpap25
Copy link
Copy Markdown
Contributor Author

micpap25 commented Jun 3, 2025

I can definitely confirm that last part, that a skip would be necessary to use these classes.

Parsing through the code I do think it's all false positives. I don't believe any abstract classes are getting instantiated. It would be nice to be able to keep the warning for real cases, but I'm not sure it's worth it with all the false positives.

@micpap25
Copy link
Copy Markdown
Contributor Author

micpap25 commented Jun 4, 2025

Not sure why anything is failing out now since all that has changed between now and the last succeeding CI was comments after the reversion...?

Oh, I see the notebooks need updating. I'll wait until there's agreement on what to do with abstract-class-instantiated.

@mpharrigan
Copy link
Copy Markdown
Collaborator

Yes, I think we should keep abstract-class-instantiated as a global skip and add a note to the pylint config that it produces too many false positives with our usage of attrs.

If we instantiate an abstract class, it will get caught at runtime (e.g. during a unit test)

@mpharrigan
Copy link
Copy Markdown
Collaborator

There's also a known flaky test at the moment #1657 , which is the pytest failure. I can re-run the CI in that case.

Copy link
Copy Markdown
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for getting these three checks fixed and enabled; and investigating the final one to be false-positives

@mpharrigan mpharrigan enabled auto-merge (squash) June 5, 2025 22:05
@mpharrigan mpharrigan merged commit 4a39b42 into quantumlib:main Jun 5, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unitaryhack Candidates for unitaryHACK 2025

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Correct lint issues exposed with update to pylint-3

3 participants