Pytorch-lightning: [Pyright] Cannot access member 'X' for type 'None'

Created on 15 Feb 2020  路  17Comments  路  Source: PyTorchLightning/pytorch-lightning

Pyright raises 89 errors on master about Cannot access member 'X' for type 'None'. Here is an example in evaluation_loop.py:

                # track outputs for collation
                dl_outputs.append(output)

                # batch done
                if test:
                    self.test_progress_bar.update(1)  # PYRIGHT ERROR
                else:
                    self.val_progress_bar.update(1)  # PYRIGHT ERROR
                    self.main_progress_bar.update(1)  # PYRIGHT ERROR
            outputs.append(dl_outputs)

        eval_results = {}

One way to fix this is to indicate the type of those variables:

self.test_progress_bar: Any = None

Unless you see a more elegant way?

Hacktoberfest enhancement good first issue help wanted

All 17 comments

This shall be fixed, may you consider sed a PR?

Not sure I would have time on the short term but I'll keep it on my TODO list.

Hi there, I am interested in solving this bug, can i work on this ?

Hi @Dev-Akash sure, that would be great!

Hi @Dev-Akash how is it going? any progress here... :rabbit:

@hadim maybe we can also add this check to CI, does it run on Linux?

You can install it with npm (see website). Sorry I don't have time to do that at the moment.

I'd be happy to take a look at this if no one else is working on it. Let me know.

CC: @Borda

@Dev-Akash still interested in finishing the type check after #2121?

@Dev-Akash still interested in finishing the type check after #2121?

Currently not able to contribute in this issue, you can unassign me from this issue.
Thank you !

@uditarora still interested in taking this over? :]

@uditarora still interested in taking this over? :]

Sure, I have some free time over the next week. Let me try and fix more Pyright errors :)

Let me know if you have something specific in mind that I should look at. Else I can pick up some module randomly.

I think that we may start with ones which are most used that e continue with others... for the most used lest doing just module by module so the PR is not pending for long... and avoid collisions

This issue has been automatically marked as stale because it hasn't had any recent activity. This issue will be closed in 7 days if no further activity occurs. Thank you for your contributions, Pytorch Lightning Team!

@uditarora how is it going here?

@uditarora how is it going here?

I made a little progress earlier but not enough to send a PR, before sadly getting caught up with school-related deadlines. I'm not sure how much I'll be able to contribute for the next month, so please feel free to assign it to someone else in the meanwhile if they're interested :)

As discussed with @Borda, I would suggest improving the typing of all the code base to make static type checking more robust! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

polars05 picture polars05  路  3Comments

jcreinhold picture jcreinhold  路  3Comments

edenlightning picture edenlightning  路  3Comments

justusschock picture justusschock  路  3Comments

williamFalcon picture williamFalcon  路  3Comments