Fix SyntaxError and NameError in multiple files#14855
Closed
ArnavGarg7 wants to merge 2 commits into
Closed
Conversation
for more information, see https://pre-commit.ci
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to fix import/collection-time failures by addressing forward-reference type annotations in maths/matrix_exponentiation.py, but the PR description/title claim additional SyntaxError fixes in web_programming/ that are not present in the actual changeset.
Changes:
- Add
from __future__ import annotationsto defer evaluation ofMatrixtype hints and avoidNameErrorduring import.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
1
to
+4
| """Matrix Exponentiation""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
Member
|
We only run on the current version of Python (3.14.6), so these changes are not needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change:
This PR fixes multiple bugs that were preventing
pytestfrom properly collecting and running tests due toSyntaxErrorandNameErrorexceptions during the import/collection phase.maths/matrix_exponentiation.py: Fixed aNameErrorwhereMatrixwas referenced in its own class methods as a type hint before it was fully defined. Resolved this by addingfrom __future__ import annotations.web_programming/fetch_well_rx_price.py: Fixed aSyntaxError: multiple exception types must be parenthesized. The code was using Python 2 exception syntax (except httpx.HTTPError, ValueError:). Updated it to the correct Python 3 syntax (except (httpx.HTTPError, ValueError):).web_programming/instagram_crawler.py: Fixed an identicalSyntaxErrorfor multiple exception types (except json.decoder.JSONDecodeError, KeyError:). Updated it toexcept (json.decoder.JSONDecodeError, KeyError):.Checklist: