-
Notifications
You must be signed in to change notification settings - Fork 7
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
WIP - Feature/custom codec #16
base: master
Are you sure you want to change the base?
Conversation
pls use a syntax that looks like python, so that various tools that highlight/parse python don't break:
some parsers/tools/highlighters might freak out over (In practice, both my primary tools - Notepad++ and Pygmentize don't have any issues with |
# Conflicts: # gql/renderer_dataclasses.py # tests/test_renderer_dataclasses.py
@aviv-ebates I thought about this too and checked the IDEs I have:
The con of using a function syntax is that it can be confused by the reader as a real function call. As far as IDEs go, I looked at how Out syntax is way simpler so it shouldn't be a problem to do the same. As for non IDE tools - like pylint, mypy etc - when they do WDYT? |
Another problem with the |
I would like for all tools - esp lints - to run on source code (i.e., what the user actually types) rather then generated code; mypy only works on the AST, but other tools (pylint) check for code formatting. I don't understand the issue with As far as the user being confused with
Also, making this section valid python would allow us to provide a good error message if the user somehow didn't load our custom encoder, rather than having the python loader error out. |
If mypy sees the generated code, it might show up errors that don't make sense to the user; I'm sort-of guessing the generated code should end up being just |
gql/codec/register.py
Outdated
codecs.register(search_function) | ||
|
||
_USAGE = """\ | ||
Wraps a python command to allow it to recognize pyxl-coded files with |
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.
pyxl-coded files...
gql/codec/register.py
Outdated
|
||
|
||
def search_function(encoding): | ||
if encoding != 'gql': |
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.
maybe have a more-unique name for the codec?
pyproject.toml
Outdated
@@ -5,6 +5,7 @@ description = "Python GraphQL Client Library" | |||
authors = ["Eran Kampf <[email protected]>"] | |||
license = "MIT" | |||
readme = "README.md" | |||
include= ["gql.pth"] |
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.
missing space before =
.
@aviv-ebates isn't the whole point of strong typing the response objects is for these tools to be able to recognize them?
I would like this code to throw some lint\mypy error that |
Like we talked offline - for some things (like "exactly 1 space before |
Allow embedding GraphQL queries in Python code.
For example:
Should render all the relevant Operation class and result dataclasses and set
GetFilm
to be the operation class: