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

Trunk Check Workflow #3787

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/trunk-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Trunk Check
run-name: ${{ fromJSON(inputs.payload).checkWorkflowRunName }}
on:
workflow_dispatch:
inputs:
payload:
description: For invocation by Trunk Check
required: false

permissions:
contents: read

jobs:
check:
name: ${{ fromJSON(inputs.payload).checkJobName }}
runs-on: ${{ fromJSON(inputs.payload).checkJobRunsOn }}
concurrency:
group: ${{ fromJSON(inputs.payload).concurrencyGroup }}
cancel-in-progress: true

steps:
- name: Trunk Check
uses: trunk-io/trunk-action@v1
with:
check-mode: payload
9 changes: 9 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
57 changes: 57 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.22.2
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.6.1
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- [email protected]
- [email protected]
- [email protected]
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
ignore:
- linters: [ALL]
paths:
- "**/*.pyi"
- linters: [bandit]
paths:
- integration/**
- tests/**
actions:
enabled:
- trunk-announce
- trunk-check-pre-push
- trunk-upgrade-available
133 changes: 76 additions & 57 deletions reflex/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,77 +14,86 @@
import platform
import sys
import traceback
from collections.abc import AsyncIterator
from collections.abc import Callable
from datetime import datetime
from pathlib import Path
from typing import (
Any,
AsyncIterator,
Callable,
Coroutine,
Dict,
List,
Optional,
Set,
Type,
Union,
get_args,
get_type_hints,
)

from fastapi import FastAPI, HTTPException, Request, UploadFile
from typing import Any
from typing import Coroutine
from typing import Dict
from typing import List
from typing import Optional
from typing import Set
from typing import Type
from typing import Union
from typing import get_args
from typing import get_type_hints

from fastapi import FastAPI
from fastapi import HTTPException
from fastapi import Request
from fastapi import UploadFile
from fastapi.middleware import cors
from fastapi.responses import StreamingResponse
from fastapi.staticfiles import StaticFiles
from rich.progress import MofNCompleteColumn, Progress, TimeElapsedColumn
from socketio import ASGIApp, AsyncNamespace, AsyncServer
from rich.progress import MofNCompleteColumn
from rich.progress import Progress
from rich.progress import TimeElapsedColumn
from socketio import ASGIApp
from socketio import AsyncNamespace
from socketio import AsyncServer
from starlette_admin.contrib.sqla.admin import Admin
from starlette_admin.contrib.sqla.view import ModelView

from reflex import constants
from reflex.admin import AdminDash
from reflex.app_mixins import AppMixin, LifespanMixin, MiddlewareMixin
from reflex.app_mixins import AppMixin
from reflex.app_mixins import LifespanMixin
from reflex.app_mixins import MiddlewareMixin
from reflex.base import Base
from reflex.compiler import compiler
from reflex.compiler import utils as compiler_utils
from reflex.compiler.compiler import ExecutorSafeFunctions
from reflex.components.base.app_wrap import AppWrap
from reflex.components.base.error_boundary import ErrorBoundary
from reflex.components.base.fragment import Fragment
from reflex.components.component import (
Component,
ComponentStyle,
evaluate_style_namespaces,
)
from reflex.components.core.banner import connection_pulser, connection_toaster
from reflex.components.component import Component
from reflex.components.component import ComponentStyle
from reflex.components.component import evaluate_style_namespaces
from reflex.components.core.banner import connection_pulser
from reflex.components.core.banner import connection_toaster
from reflex.components.core.breakpoints import set_breakpoints
from reflex.components.core.client_side_routing import (
Default404Page,
wait_for_client_redirect,
)
from reflex.components.core.upload import Upload, get_upload_dir
from reflex.components.core.client_side_routing import Default404Page
from reflex.components.core.client_side_routing import wait_for_client_redirect
from reflex.components.core.upload import Upload
from reflex.components.core.upload import get_upload_dir
from reflex.components.radix import themes
from reflex.config import get_config
from reflex.event import Event, EventHandler, EventSpec, window_alert
from reflex.event import Event
from reflex.event import EventHandler
from reflex.event import EventSpec
from reflex.event import window_alert
from reflex.model import Model
from reflex.page import (
DECORATED_PAGES,
)
from reflex.route import (
get_route_args,
replace_brackets_with_keywords,
verify_route_validity,
)
from reflex.state import (
BaseState,
RouterData,
State,
StateManager,
StateUpdate,
_substate_key,
code_uses_state_contexts,
)
from reflex.utils import codespaces, console, exceptions, format, prerequisites, types
from reflex.utils.exec import is_prod_mode, is_testing_env, should_skip_compile
from reflex.page import DECORATED_PAGES
from reflex.route import get_route_args
from reflex.route import replace_brackets_with_keywords
from reflex.route import verify_route_validity
from reflex.state import BaseState
from reflex.state import RouterData
from reflex.state import State
from reflex.state import StateManager
from reflex.state import StateUpdate
from reflex.state import _substate_key
from reflex.state import code_uses_state_contexts
from reflex.utils import codespaces
from reflex.utils import console
from reflex.utils import exceptions
from reflex.utils import format
from reflex.utils import prerequisites
from reflex.utils import types
from reflex.utils.exec import is_prod_mode
from reflex.utils.exec import is_testing_env
from reflex.utils.exec import should_skip_compile
from reflex.utils.imports import ImportVar

# Define custom types.
Expand Down Expand Up @@ -112,7 +121,8 @@ def default_backend_exception_handler(exception: Exception) -> EventSpec:
EventSpec: The window alert event.

"""
from reflex.components.sonner.toast import Toaster, toast
from reflex.components.sonner.toast import Toaster
from reflex.components.sonner.toast import toast

error = traceback.format_exc()

Expand Down Expand Up @@ -481,11 +491,19 @@ def add_page(
"""
# If the route is not set, get it from the callable.
if route is None:
assert isinstance(
component, Callable
), "Route must be set if component is not a callable."
# Format the route.
route = format.format_route(component.__name__)
match component:
case Callable():
# Format the route.
route = format.format_route(
route=component.__name__,
)

case _:
error_msg: str = "Route must be set if component is not a callable."
raise TypeError(
error_msg,
)

else:
route = format.format_route(route, format_case=False)

Expand Down Expand Up @@ -1343,7 +1361,8 @@ async def upload_file(request: Request, files: List[UploadFile]):
UploadTypeError: if a background task is used as the handler.
HTTPException: when the request does not include token / handler headers.
"""
from reflex.utils.exceptions import UploadTypeError, UploadValueError
from reflex.utils.exceptions import UploadTypeError
from reflex.utils.exceptions import UploadValueError

token = request.headers.get("reflex-client-token")
handler = request.headers.get("reflex-event-handler")
Expand Down
Loading