Skip to content
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

Private fields not private in Python 3.12. #3358

Closed
rsr5 opened this issue Jan 24, 2024 · 5 comments
Closed

Private fields not private in Python 3.12. #3358

rsr5 opened this issue Jan 24, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@rsr5
Copy link

rsr5 commented Jan 24, 2024

Describe the Bug

Private fields not private in Python 3.12. I reproduced with the following code:

import strawberry

@strawberry.type
class User:
    name: str
    age: int
    secret: str = strawberry.Private[str]

@strawberry.type
class Query:
    @strawberry.field
    def user(self) -> User:
        return User(name="Patrick", age=100, secret="can't tell")

schema = strawberry.Schema(query=Query)

and I see the following at http://0.0.0.0:8000/graphql:

image

System Information

  • Operating system: Apple M1 Sonoma | Python 3.12
  • Strawberry version (if applicable): 0.218.1

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@rsr5 rsr5 added the bug Something isn't working label Jan 24, 2024
@patrick91
Copy link
Member

@rsr5 oh, that's unexpected! I'll check this today!

@patrick91
Copy link
Member

@rsr5 ah! there's a small issue with your snippet:

import strawberry

@strawberry.type
class User:
    name: str
    age: int
-    secret: str = strawberry.Private[str]
+    secret: strawberry.Private[str]

@strawberry.type
class Query:
    @strawberry.field
    def user(self) -> User:
        return User(name="Patrick", age=100, secret="can't tell")

schema = strawberry.Schema(query=Query)

@rsr5
Copy link
Author

rsr5 commented Jan 24, 2024

Well spotted! I just realised that as well. I was trying to reproduce something we are seeing in a larger project. I will have to keep trying!

@rsr5 rsr5 closed this as completed Jan 24, 2024
@patrick91
Copy link
Member

@rsr5 happy to do a call if you need help 😊

@rsr5
Copy link
Author

rsr5 commented Jan 24, 2024

Very kind of you. I will have another go at reproducing first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants