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

NoneType issue when calling _update_attributes in users #1169

Open
travishathaway opened this issue Dec 15, 2023 · 2 comments
Open

NoneType issue when calling _update_attributes in users #1169

travishathaway opened this issue Dec 15, 2023 · 2 comments

Comments

@travishathaway
Copy link

travishathaway commented Dec 15, 2023

Traceback:

Traceback (most recent call last):
  File "/Users/computeruser/dev/issue-metrics/issue_metrics.py", line 327, in <module>
    main()
  File "/Users/computeruser/dev/issue-metrics/issue_metrics.py", line 282, in main
    issues_with_metrics, num_issues_open, num_issues_closed = get_per_issue_metrics(
                                                              ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/computeruser/dev/issue-metrics/issue_metrics.py", line 184, in get_per_issue_metrics
    issue_with_metrics.label_metrics = get_label_metrics(issue, labels)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/computeruser/dev/issue-metrics/labels.py", line 45, in get_label_metrics
    label_events = get_label_events(issue, labels)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/computeruser/dev/issue-metrics/labels.py", line 26, in get_label_events
    for event in issue.issue.events():
  File "/Users/computeruser/micromamba/envs/issue-metrics/lib/python3.11/site-packages/github3/structs.py", line 131, in __iter__
    yield cls(i)
          ^^^^^^
  File "/Users/computeruser/micromamba/envs/issue-metrics/lib/python3.11/site-packages/github3/models.py", line 52, in __init__
    self._update_attributes(json)
  File "/Users/computeruser/micromamba/envs/issue-metrics/lib/python3.11/site-packages/github3/issues/event.py", line 63, in _update_attributes
    self.actor = users.ShortUser(event["actor"], self)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/computeruser/micromamba/envs/issue-metrics/lib/python3.11/site-packages/github3/models.py", line 52, in __init__
    self._update_attributes(json)
  File "/Users/computeruser/micromamba/envs/issue-metrics/lib/python3.11/site-packages/github3/users.py", line 309, in _update_attributes
    self.avatar_url = user["avatar_url"]
                      ~~~~^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable

adding this to _update_attributes seems to have resolved this issue:

def _update_attributes(self, user):
    if user is not None:
        self.avatar_url = user["avatar_url"]
        self.events_urlt = URITemplate(user["events_url"])
        self.followers_url = user["followers_url"]
        self.following_urlt = URITemplate(user["following_url"])
        self.gists_urlt = URITemplate(user["gists_url"])
        self.gravatar_id = user["gravatar_id"]
        self.html_url = user["html_url"]
        self.id = user["id"]
        self.login = user["login"]
        self.organizations_url = user["organizations_url"]
        self.received_events_url = user["received_events_url"]
        self.repos_url = user["repos_url"]
        self.site_admin = user.get("site_admin")
        self.starred_urlt = URITemplate(user["starred_url"])
        self.subscriptions_url = user["subscriptions_url"]
        self.type = user["type"]
        self.url = self._api = user["url"]
        self._uniq = self.id
@travishathaway
Copy link
Author

I ran across this while using this project:

@sigmavirus24
Copy link
Owner

#1161 or something like it would fix this nicely if you're interested in sending a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants