Skip to content

Assert parent is not None #2110

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

Closed
wants to merge 1 commit into from
Closed

Conversation

nickdrozd
Copy link
Contributor

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

Fixes one Mypy error.

@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Merging #2110 (3d599e9) into main (a8a8593) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2110   +/-   ##
=======================================
  Coverage   92.75%   92.75%           
=======================================
  Files          94       94           
  Lines       11004    11005    +1     
=======================================
+ Hits        10207    10208    +1     
  Misses        797      797           
Flag Coverage Ξ”
linux 92.52% <100.00%> (+<0.01%) ⬆️
pypy 88.05% <100.00%> (+<0.01%) ⬆️
windows 92.31% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Ξ”
astroid/nodes/node_classes.py 94.90% <100.00%> (+<0.01%) ⬆️

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

I think we should think about making this some sort of generic attribute of NodeNG. There are lots of nodes where we know that parent is not None. Not having to put asserts everywhere would be much better, but I haven't had the time to look into how to do this properly.

@Pierre-Sassoulas Pierre-Sassoulas added the Maintenance Discussion or action around maintaining astroid or the dev workflow label Apr 5, 2023
@nickdrozd
Copy link
Contributor Author

When is it possible for there to be no parent? Just for modules?

@nickdrozd
Copy link
Contributor Author

As far as assertions go, I think it's worth adding them if it helps getting Mypy running without errors.

@DanielNoord DanielNoord added this to the 2.16.0 milestone Apr 7, 2023
@DanielNoord DanielNoord added the Enhancement ✨ Improvement to a component label Apr 7, 2023
@DanielNoord
Copy link
Collaborator

When is it possible for there to be no parent? Just for modules?

I think so, but also for nodes that are constructed out of thin air. We do that quite often.

As far as assertions go, I think it's worth adding them if it helps getting Mypy running without errors.

I don't think so. Asserts change behaviour and can make pylint crash. We should only add them if we know they are true and can't find any other way to express what they are testing.

@jacobtylerwalls
Copy link
Member

I think so, but also for nodes that are constructed out of thin air. We do that quite often.

The brains do this all over the place, see #1490 (comment).

@nickdrozd nickdrozd closed this Apr 10, 2023
@nickdrozd nickdrozd deleted the check-parent branch April 10, 2023 13:20
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.16.0, 3.0 Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Maintenance Discussion or action around maintaining astroid or the dev workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants