Skip to content

unsupported operand type(s) for |: type and type #15

@mbnoimi

Description

@mbnoimi
$ bash init.sh 
Run migrations
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
Create initial data in DB
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/laptop/playground/backend/api/app/initial_data.py", line 12, in <module>
    from app.core import config, security
  File "/home/laptop/playground/backend/api/app/core/security.py", line 55, in <module>
    def generate_access_token_response(subject: str | int):
TypeError: unsupported operand type(s) for |: 'type' and 'type'

The following line throws an error during executing bash init.sh

class JWTTokenPayload(BaseModel):
    sub: str | int #-----> This line
    refresh: bool
    issued_at: int
    expires_at: int

I fixed it by using sub: str and modifying the other related methods.

What's wrong with sub: str | int ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions