8000 refactor: add type hints by ninoseki · Pull Request #159 · VirusTotal/vt-py · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor: add type hints #159

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

Merged
merged 1 commit into from
Sep 9, 2023
Merged

Conversation

ninoseki
Copy link
Contributor
@ninoseki ninoseki commented Sep 8, 2023

I re-created #43 because it becomes too old.

I believe adding type hints enhances vt-py's user experience. So I'd appreciate if you could give your time to review this PR.

For example,

Before

Screenshot 2023-09-09 at 9 30 28

obj from the iterator is Unknown.

After

Screenshot 2023-09-09 at 9 29 51

obj from the iterator is Object.

Thus IDE can suggest auto-completion.

Screenshot 2023-09-09 at 9 30 13

@ninoseki ninoseki force-pushed the add-type-annotations branch from 1e2362b to c8ee28b Compare September 9, 2023 00:29
@plusvic plusvic merged commit afdebaa into VirusTotal:master Sep 9, 2023
plusvic added a commit that referenced this pull request Sep 9, 2023
The test suite is failing with this strange error:

```
tests/test_client.py:21: in <module>
    from vt import APIError
vt/__init__.py:17: in <module>
    from .client import *
vt/client.py:177: in <module>
    class Client:
vt/client.py:385: in Client
    sleep_time: int = 20
E   TypeError: 'type' object is not subscriptable
```

I'm not sure what's happening here, I'm not very familiar with Python 3 type hints mechanism.
@plusvic
Copy link
Member
plusvic commented Sep 9, 2023

I had to revert this change because the test suite started failing. First it was the linter:

Run pylint --rcfile pylintrc vt/ tests examples/
************* Module vt.client
vt/client.py:382:12: E[11](https://github.com/VirusTotal/vt-py/actions/runs/6129601871/job/16637863581#step:5:12)36: Value 'list' is unsubscriptable (unsubscriptable-object)
vt/client.py:404:[12](https://github.com/VirusTotal/vt-py/actions/runs/6129601871/job/16637863581#step:5:13): E1[13](https://github.com/VirusTotal/vt-py/actions/runs/6129601871/job/16637863581#step:5:14)6: Value 'list' is unsubscriptable (unsubscriptable-object)

I thought it was just a linting issue, but after disabling the unsubscriptable-object, it started failing while running the tests:

tests/test_iterator.py:19: in <module>
    import vt
vt/__init__.py:17: in <module>
    from .client import *
vt/client.py:177: in <module>
    class Client:
vt/client.py:385: in Client
    sleep_time: int = 20
E   TypeError: 'type' object is not subscriptable

I'm not sure what's happening here, the error message is quite confusing.

@ninoseki
Copy link
Contributor Author
8000 ninoseki commented Sep 9, 2023

@plusvic Sorry it's totally my bad that I didn't test the PR with Python 3.7 and didn't apply pylint in tests directory. (I just did pylint vt/)
I fixed the issue my PR has and now all tests are green. Is it okay to re-create PR again?

Screenshot 2023-09-09 at 18 49 16
(https://github.com/ninoseki/vt-py/actions/runs/6130207220)

@mgmacias95
Copy link
Member

hello @ninoseki,

Please, recreate the PR.

Thanks!

This was referenced Sep 11, 2023
@ninoseki
Copy link
Contributor Author

Thanks I re-created the PR as #161.

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

Successfully merging this pull request may close these issues.

3 participants
0