-
Notifications
You must be signed in to change notification settings - Fork 871
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
pyright
fixes
#3777
pyright
fixes
#3777
Conversation
WalkthroughThis update focuses on enhancing error handling, initializing variables before use, and refining logic in a Python project. Changes include adding or adjusting timeouts for HTTP requests, initializing variables to prevent bugs, and refining data handling in functions. The modifications aim to improve stability, readability, and maintainability of the codebase, ensuring smoother operations and clearer error reporting. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@janosh Please review this, all Not sure why |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great, thanks so much! @ml-evs will be happy to hear this :)
i think pyright
is failing in pre-commit CI because it can't find the dependencies installed into a virtual env. try adding to pyproject.toml
(CC @njzjz)
[tool.pyright]
venv = "pmg"
venvPath = "~/micromamba/envs" # TODO check this path is correct, not sure where micromamba puts envs
Thanks for the input. I'll have a try. Just tried to install #3777 (comment) This has to be confirmed :) |
sorry, actually this was a stupid suggestion. i thought |
This reverts commit f9a3aeb.
I think the reason is that pre-commit.ci disallows the network at the runtime (see pre-commit-ci/issues#196 (comment)), but pyright-python only downloads pyright at the first runtime (see RobertCraigie/pyright-python#225). |
thanks @njzjz! that's good to know. more reason to skip it in pre-commit CI. @DanielYang59 could you add pymatgen/.pre-commit-config.yaml Line 5 in ad6eafe
|
Thanks @njzjz! It's very helpful. |
@janosh. Yes it makes sense, we may not need |
Ah, wait! I'm pretty sure I added a timeout of 60 seconds for self = <ext.test_cod.TestCOD testMethod=test_get_structure_by_id>
def test_get_structure_by_id(self):
> struct = COD().get_structure_by_id(2002926)
tests/ext/test_cod.py:31:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pymatgen/ext/cod.py:93: in get_structure_by_id
response = requests.get(f"http://{self.url}/cod/{cod_id}.cif", timeout=60)
../../../micromamba/envs/pmg/lib/python3.11/site-packages/requests/api.py:73: in get
return request("get", url, params=params, **kwargs)
../../../micromamba/envs/pmg/lib/python3.11/site-packages/requests/api.py:59: in request
return session.request(method=method, url=url, **kwargs)
../../../micromamba/envs/pmg/lib/python3.11/site-packages/requests/sessions.py:589: in request
resp = self.send(prep, **send_kwargs)
../../../micromamba/envs/pmg/lib/python3.11/site-packages/requests/sessions.py:703: in send
r = adapter.send(request, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <requests.adapters.HTTPAdapter object at 0x7f3737f1e250>
request = <PreparedRequest [GET]>, stream = False
timeout = Timeout(connect=60, read=60, total=None), verify = True, cert = None
proxies = OrderedDict() |
feel free to skip the COD test as well. pinging live APIs in CI is bad practice anyway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Out of diff range and nitpick comments (1)
pymatgen/ext/cod.py (1)
60-60
: Consider addressing the TODO to remove dependency on external mysql call.
@janosh. I notice CI is failing after this PR (more specifically after the merge master commit a297ef8). It's also failing locally. Did we actually break anything? UPDATE: I just opened #3781 to fix this. Seems like a typo in #3771? |
thanks for the quick fix! |
btw, very happy that we can enable |
Great to know that! And very glad I could help :) |
Summary
pyright
fixes, a follow up PR ofpyright
fixes forext/io/phonon/symmetry/transformations/util/vis/dev_scripts
and improveio.lobster
#3757.pyright
in linting workflow andpre-commit
.