Skip to content

Commit

Permalink
Merge pull request #288 from lsst/tickets/DM-47796
Browse files Browse the repository at this point in the history
DM-47796: Update project templates for new Ruff
  • Loading branch information
rra authored Nov 25, 2024
2 parents 8238896 + c0293c5 commit b67f88a
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.8.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ ignore = [
"S607", # using PATH is not a security vulnerability
"SIM102", # sometimes the formatting of nested if statements is clearer
"SIM117", # sometimes nested with contexts are clearer
"TCH001", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH002", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH003", # we decided to not maintain separate TYPE_CHECKING blocks
"TC001", # we decided to not maintain separate TYPE_CHECKING blocks
"TC002", # we decided to not maintain separate TYPE_CHECKING blocks
"TC003", # we decided to not maintain separate TYPE_CHECKING blocks
"TD003", # we don't require issues be created for TODOs
"TID252", # if we're going to use relative imports, use them always
"TRY003", # good general advice but lint is way too aggressive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ..config import config
from ..models import Index

__all__ = ["get_index", "external_router"]
__all__ = ["external_router"]

external_router = APIRouter()
"""FastAPI router for all external handlers."""
Expand All @@ -22,24 +22,21 @@
"Document the top-level API here. By default it only returns metadata"
" about the application."
),
response_model=Index,
response_model_exclude_none=True,
summary="Application metadata",
)
async def get_index(
logger: Annotated[BoundLogger, Depends(logger_dependency)],
) -> Index:
"""GET ``/example-uws/`` (the app's external root).
# Customize this handler to return whatever the top-level resource of your
# application should return. For example, consider listing key API URLs.
# When doing so, also change or customize the response model in
# exampleuws.models.Index.
#
# By convention, the root of the external API includes a field called
# metadata that provides the same Safir-generated metadata as the internal
# root endpoint.

Customize this handler to return whatever the top-level resource of your
application should return. For example, consider listing key API URLs.
When doing so, also change or customize the response model in
`exampleuws.models.Index`.
By convention, the root of the external API includes a field called
``metadata`` that provides the same Safir-generated metadata as the
internal root endpoint.
"""
# There is no need to log simple requests since uvicorn will do this
# automatically, but this is included as an example of how to use the
# logger for more complex logging.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from ..config import config

__all__ = ["get_index", "internal_router"]
__all__ = ["internal_router"]

internal_router = APIRouter()
"""FastAPI router for all internal handlers."""
Expand All @@ -27,15 +27,10 @@
" therefore cannot be used by external clients."
),
include_in_schema=False,
response_model=Metadata,
response_model_exclude_none=True,
summary="Application metadata",
)
async def get_index() -> Metadata:
"""GET ``/`` (the app's internal root).
By convention, this endpoint returns only the application's metadata.
"""
return get_metadata(
package_name="example-uws",
application_name=config.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.8.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
6 changes: 3 additions & 3 deletions project_templates/fastapi_safir_app/example/ruff-shared.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ ignore = [
"S607", # using PATH is not a security vulnerability
"SIM102", # sometimes the formatting of nested if statements is clearer
"SIM117", # sometimes nested with contexts are clearer
"TCH001", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH002", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH003", # we decided to not maintain separate TYPE_CHECKING blocks
"TC001", # we decided to not maintain separate TYPE_CHECKING blocks
"TC002", # we decided to not maintain separate TYPE_CHECKING blocks
"TC003", # we decided to not maintain separate TYPE_CHECKING blocks
"TD003", # we don't require issues be created for TODOs
"TID252", # if we're going to use relative imports, use them always
"TRY003", # good general advice but lint is way too aggressive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ..config import config
from ..models import Index

__all__ = ["get_index", "external_router"]
__all__ = ["external_router"]

external_router = APIRouter()
"""FastAPI router for all external handlers."""
Expand All @@ -22,24 +22,21 @@
"Document the top-level API here. By default it only returns metadata"
" about the application."
),
response_model=Index,
response_model_exclude_none=True,
summary="Application metadata",
)
async def get_index(
logger: Annotated[BoundLogger, Depends(logger_dependency)],
) -> Index:
"""GET ``/example/`` (the app's external root).
# Customize this handler to return whatever the top-level resource of your
# application should return. For example, consider listing key API URLs.
# When doing so, also change or customize the response model in
# example.models.Index.
#
# By convention, the root of the external API includes a field called
# metadata that provides the same Safir-generated metadata as the internal
# root endpoint.

Customize this handler to return whatever the top-level resource of your
application should return. For example, consider listing key API URLs.
When doing so, also change or customize the response model in
`example.models.Index`.
By convention, the root of the external API includes a field called
``metadata`` that provides the same Safir-generated metadata as the
internal root endpoint.
"""
# There is no need to log simple requests since uvicorn will do this
# automatically, but this is included as an example of how to use the
# logger for more complex logging.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from ..config import config

__all__ = ["get_index", "internal_router"]
__all__ = ["internal_router"]

internal_router = APIRouter()
"""FastAPI router for all internal handlers."""
Expand All @@ -27,15 +27,10 @@
" therefore cannot be used by external clients."
),
include_in_schema=False,
response_model=Metadata,
response_model_exclude_none=True,
summary="Application metadata",
)
async def get_index() -> Metadata:
"""GET ``/`` (the app's internal root).
By convention, this endpoint returns only the application's metadata.
"""
return get_metadata(
package_name="example",
application_name=config.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.8.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ ignore = [
"S607", # using PATH is not a security vulnerability
"SIM102", # sometimes the formatting of nested if statements is clearer
"SIM117", # sometimes nested with contexts are clearer
"TCH001", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH002", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH003", # we decided to not maintain separate TYPE_CHECKING blocks
"TC001", # we decided to not maintain separate TYPE_CHECKING blocks
"TC002", # we decided to not maintain separate TYPE_CHECKING blocks
"TC003", # we decided to not maintain separate TYPE_CHECKING blocks
"TD003", # we don't require issues be created for TODOs
"TID252", # if we're going to use relative imports, use them always
"TRY003", # good general advice but lint is way too aggressive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ..config import config
from ..models import Index

__all__ = ["get_index", "external_router"]
__all__ = ["external_router"]

external_router = APIRouter()
"""FastAPI router for all external handlers."""
Expand All @@ -22,24 +22,21 @@
"Document the top-level API here. By default it only returns metadata"
" about the application."
),
response_model=Index,
response_model_exclude_none=True,
summary="Application metadata",
)
async def get_index(
logger: Annotated[BoundLogger, Depends(logger_dependency)],
) -> Index:
"""GET ``/{{ cookiecutter.name | lower }}/`` (the app's external root).
# Customize this handler to return whatever the top-level resource of your
# application should return. For example, consider listing key API URLs.
# When doing so, also change or customize the response model in
# {{ cookiecutter.module_name }}.models.Index.
#
# By convention, the root of the external API includes a field called
# metadata that provides the same Safir-generated metadata as the internal
# root endpoint.

Customize this handler to return whatever the top-level resource of your
application should return. For example, consider listing key API URLs.
When doing so, also change or customize the response model in
`{{ cookiecutter.module_name }}.models.Index`.
By convention, the root of the external API includes a field called
``metadata`` that provides the same Safir-generated metadata as the
internal root endpoint.
"""
# There is no need to log simple requests since uvicorn will do this
# automatically, but this is included as an example of how to use the
# logger for more complex logging.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from ..config import config

__all__ = ["get_index", "internal_router"]
__all__ = ["internal_router"]

internal_router = APIRouter()
"""FastAPI router for all internal handlers."""
Expand All @@ -27,15 +27,10 @@
" therefore cannot be used by external clients."
),
include_in_schema=False,
response_model=Metadata,
response_model_exclude_none=True,
summary="Application metadata",
)
async def get_index() -> Metadata:
"""GET ``/`` (the app's internal root).
By convention, this endpoint returns only the application's metadata.
"""
return get_metadata(
package_name="{{ cookiecutter.name }}",
application_name=config.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.8.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ ignore = [
"S607", # using PATH is not a security vulnerability
"SIM102", # sometimes the formatting of nested if statements is clearer
"SIM117", # sometimes nested with contexts are clearer
"TCH001", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH002", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH003", # we decided to not maintain separate TYPE_CHECKING blocks
"TC001", # we decided to not maintain separate TYPE_CHECKING blocks
"TC002", # we decided to not maintain separate TYPE_CHECKING blocks
"TC003", # we decided to not maintain separate TYPE_CHECKING blocks
"TD003", # we don't require issues be created for TODOs
"TID252", # if we're going to use relative imports, use them always
"TRY003", # good general advice but lint is way too aggressive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.8.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ ignore = [
"S607", # using PATH is not a security vulnerability
"SIM102", # sometimes the formatting of nested if statements is clearer
"SIM117", # sometimes nested with contexts are clearer
"TCH001", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH002", # we decided to not maintain separate TYPE_CHECKING blocks
"TCH003", # we decided to not maintain separate TYPE_CHECKING blocks
"TC001", # we decided to not maintain separate TYPE_CHECKING blocks
"TC002", # we decided to not maintain separate TYPE_CHECKING blocks
"TC003", # we decided to not maintain separate TYPE_CHECKING blocks
"TD003", # we don't require issues be created for TODOs
"TID252", # if we're going to use relative imports, use them always
"TRY003", # good general advice but lint is way too aggressive
Expand Down
2 changes: 1 addition & 1 deletion project_templates/technote_md/testn-000/technote.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ series_id = "TESTN"
canonical_url = "https://testn-000.lsst.io"
github_url = "https://github.com/lsst/testn-000"
github_default_branch = "main"
date_created = 2024-11-19T23:58:23Z
date_created = 2024-11-25T21:31:10Z
organization.name = "Vera C. Rubin Observatory"
organization.ror = "https://ror.org/048g3cy84"
license.id = "CC-BY-4.0"
Expand Down
2 changes: 1 addition & 1 deletion project_templates/technote_rst/testn-000/technote.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ series_id = "TESTN"
canonical_url = "https://testn-000.lsst.io"
github_url = "https://github.com/lsst/testn-000"
github_default_branch = "main"
date_created = 2024-11-19T23:58:23Z
date_created = 2024-11-25T21:31:10Z
organization.name = "Vera C. Rubin Observatory"
organization.ror = "https://ror.org/048g3cy84"
license.id = "CC-BY-4.0"
Expand Down

0 comments on commit b67f88a

Please sign in to comment.