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 additional mypy errors and expand CI checks to more files #2541

Merged
merged 3 commits into from
Sep 7, 2024

Conversation

correctmost
Copy link
Contributor

Type of Changes

Type
🔨 Refactoring

Description

Clean-up of some of the simpler mypy errors.

The import changes are to fix errors like this:

astroid/brain/brain_namedtuple_enum.py:16: error: Module "astroid" does not explicitly export attribute "inference_tip"  [attr-defined]

Copy link

codecov bot commented Sep 4, 2024

Codecov Report

Attention: Patch coverage is 98.76543% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.86%. Comparing base (78f7f60) to head (c905d35).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
astroid/brain/brain_hypothesis.py 66.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2541      +/-   ##
==========================================
- Coverage   92.98%   92.86%   -0.13%     
==========================================
  Files          93       93              
  Lines       11048    11081      +33     
==========================================
+ Hits        10273    10290      +17     
- Misses        775      791      +16     
Flag Coverage Δ
linux 92.86% <98.76%> (+<0.01%) ⬆️
pypy ?
windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
astroid/_ast.py 100.00% <100.00%> (ø)
astroid/brain/brain_argparse.py 96.00% <100.00%> (+0.16%) ⬆️
astroid/brain/brain_boto3.py 69.23% <100.00%> (ø)
astroid/brain/brain_builtin_inference.py 92.05% <100.00%> (-0.20%) ⬇️
astroid/brain/brain_crypt.py 100.00% <100.00%> (ø)
astroid/brain/brain_ctypes.py 100.00% <100.00%> (ø)
astroid/brain/brain_curses.py 100.00% <100.00%> (ø)
astroid/brain/brain_datetime.py 100.00% <100.00%> (ø)
astroid/brain/brain_dateutil.py 100.00% <100.00%> (ø)
astroid/brain/brain_functools.py 98.76% <100.00%> (+0.01%) ⬆️
... and 26 more

... and 5 files with indirect coverage changes

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Wow, amazing that you were able to activate so much files at once and use nodes.X type import style without triggering a cyclic import. This is great work, and very important work on the path to make astroid really faster in the future 👏. (refs #2014)

I'm going to wait for a review by Daniel, Marc or Jacob that are more knowledgeable in astroid typing than myself but this is 🔥

@Pierre-Sassoulas Pierre-Sassoulas added the Maintenance Discussion or action around maintaining astroid or the dev workflow label Sep 4, 2024
"astroid/_ast.py",
"astroid/_backport_stdlib_names.py",
"astroid/astroid_manager.py",
"astroid/brain/brain_crypt.py",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use globs here? And just enable for all of brain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The brain directory still has a few hundred errors with the current settings: Found 297 errors in 25 files

I cleaned up a lot of the simpler errors, so I think further progress will come a few files at a time.

"""Given that the FunctionDef is decorated with @st.composite, remove the
first argument (`draw`) - it's always supplied by Hypothesis so we don't
need to emit the no-value-for-parameter lint.
"""
del node.args.args[0]
del node.args.args[0] # type: ignore[union-attr]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we do asserts here? Instead of ignoring?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, updated

"""Given that the FunctionDef is decorated with @st.composite, remove the
first argument (`draw`) - it's always supplied by Hypothesis so we don't
need to emit the no-value-for-parameter lint.
"""
if TYPE_CHECKING:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is better to actually do this assert always. mypy is showing us we have unsafe code, we should make it safe by asserting our assumption so we can see where they don't hold and handle it accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. I wasn't sure about potential performance implications, but we can optimize later if necessary.

The PR has been updated.

@Pierre-Sassoulas Pierre-Sassoulas merged commit 887668b into pylint-dev:main Sep 7, 2024
19 of 20 checks passed
@correctmost correctmost deleted the cm/expand-mypy-checks branch September 7, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Discussion or action around maintaining astroid or the dev workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants