-
Notifications
You must be signed in to change notification settings - Fork 52
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
Implement mypy
#60
Implement mypy
#60
Conversation
# type: ignore had to be added to the HTTP client. The client needs to be refactored, see: surrealdb#59
This PR is a draft until the GitHub action passes. |
Most notable breaking change is here. Also, the |
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.
Potential duplicated code that you missed?
@@ -562,15 +540,15 @@ class Surreal:
),
)
_validate_response(response, SurrealPermissionException)
- # success: ResponseSuccess = _validate_response(
- # response, SurrealPermissionException
- # )
- # return success.result
+ success: ResponseSuccess = _validate_response(
+ response, SurrealPermissionException
+ )
+ return success.result
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.
Looks good to me!
I see that the PR is not a draft now. Does that mean that you have tested and confirmed the GitHub action works as expected? |
I think the way we connect and such will eventually need to be refactored 🤔 Would need some time tough to think and see what the implications of this change are 🤔 What is your reasoning for the change? |
Yes, it is working. You can see the output here. |
I have a couple of reasons (I am open to suggestions/feedback!):
This example is confusing because you don't know what database db = Surreal()
db.connect("url/1")
db.query("query_1")
db.connect("url/2")
db.query("query_2") As opposed to db_1 = Surreal("url/1")
db_2 = Surreal("url/2")
db_1.connect()
db_1.query("query_1")
db_2.connect()
db_2.query("query_2") Let me know if I have missed anything! 👍🏻 |
We have talked about this internally, also how it will be with Rust going forward, and it seems the best is indeed to have the URL just go into the Surreal class, but also just get rid of db_1 = await Surreal("url/1")
db_2 = await Surreal("url/2")
db_1.query("query_1")
db_2.query("query_2") |
Ah, great. However, I think it would be important to keep the To give some examples of my proposal: db = Surreal("url/1")
await db.connect()
await db.query("query_1")
await db.disconnect() And async with Surreal("url/1"):
await db.query("query_1") What do you think? |
Hey @Ce11an, I'd like to suggest a few more changes to the I did some refactoring to make some parts of the code more robust. Please check out the [git] diff and see what you can use from the changes. Thanks! |
Great - Thanks 😄 Might be worth creating an issue or doing a separate PR for the proposed changes as I don't want to change too much in this PR 😅 |
Understandable. Fixes to the type hints aren't really within scope for this PR, so it is more appropriate to make further corrections to the type annotations in a separate PR. Thanks! |
@AlexFrid What do you think about the changes purposed? I am working on a PR for unit tests and they depend on whether this PR gets merged or not. I've been learning Rust. It looks like the |
Yeah, I think the changes make sense. But I could think of that in a different PR, I think the changes made here make sense and don't want to unnecessarily delay this progress, so I'll be merging this but waiting a bit before releasing a new version on PyPi, which will most likely happen end of this week or beginning of next as the docs will need updating as well. |
Thank you for submitting this pull request! We appreciate you spending the time to work on these changes.
What is the motivation?
Adding a static type checker.
mypy
makes it easier to find bugs with less debugging.Type of Change
What does this change do?
mypy
.mypy
andblack
to GitHub Actions.What is your testing strategy?
mypy runs with no errors. API documentation will be updated with any breaking changes. From discussing with @AlexFrid (#59), it was agreed that
mypy
errors can be ignored until the HTTP client has been refactored.Is this related to any issues?
#39
Have you read the Contributing Guidelines?