Skip to content

Commit 78af67c

Browse files
authored
Add pre-commit with first config and first formatting pass (#33)
1 parent ae64700 commit 78af67c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+200
-193
lines changed

.github/workflows/build-docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ jobs:
1212
python-version: 3.8
1313
- name: Install Dependencies
1414
run: pip install hatch
15-
- run: hatch run docs_deploy
15+
- run: hatch run docs_deploy

.github/workflows/publish.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
env:
2727
HATCH_INDEX_USER: __token__
2828
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
29-
run: hatch publish
29+
run: hatch publish

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ jobs:
9292
- name: Coverage Report
9393
run: hatch run cov
9494
- name: Upload coverage
95-
uses: codecov/codecov-action@v3
95+
uses: codecov/codecov-action@v3

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ site
1515
.cache
1616
__pycache__/
1717
.pytest_cache/
18-
.examples/
18+
.examples/

.pre-commit-config.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.3.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-toml
9+
- id: check-yaml
10+
args:
11+
- --unsafe
12+
- id: end-of-file-fixer
13+
- id: trailing-whitespace
14+
- repo: https://github.com/asottile/pyupgrade
15+
rev: v3.2.3
16+
hooks:
17+
- id: pyupgrade
18+
args:
19+
- --py3-plus
20+
- --keep-runtime-typing
21+
- repo: https://github.com/charliermarsh/ruff-pre-commit
22+
rev: v0.0.146
23+
hooks:
24+
- id: ruff
25+
args:
26+
- --fix
27+
- repo: https://github.com/psf/black
28+
rev: 22.10.0
29+
hooks:
30+
- id: black

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Changelog
22

3-
Please check [this page in the documentation](https://jowilf.github.io/starlette-admin/changelog/).
3+
Please check [this page in the documentation](https://jowilf.github.io/starlette-admin/changelog/).

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* [MongoEngine](http://mongoengine.org/)
4646
* [ODMantic](http://mongoengine.org/)
4747
- Custom backend ([doc](https://jowilf.github.io/starlette-admin/advanced/base-model-view/), [example](https://github.com/jowilf/starlette-admin/tree/main/examples/custom-backend))
48-
48+
4949

5050
## Installation
5151

@@ -109,4 +109,4 @@ Access your admin interface in your browser at [http://localhost:8000/admin](htt
109109
- [flatpickr](https://flatpickr.js.org/)
110110
- [moment](http://momentjs.com/)
111111
- [jsoneditor](https://github.com/josdejong/jsoneditor)
112-
- [fontawesome](https://fontawesome.com/)
112+
- [fontawesome](https://fontawesome.com/)

docs/advanced/base-model-view.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class PostView(BaseModelView):
7171

7272
## Fields
7373

74-
Internally, *Starlette-Admin* uses custom fields all inherit from [BaseField][starlette_admin.fields.BaseField] to
74+
Internally, *Starlette-Admin* uses custom fields all inherit from [BaseField][starlette_admin.fields.BaseField] to
7575
represent each attribute. So, you need to choose the right field for each attribute or create a new field if needed.
7676
See [API Reference][starlette_admin.fields.BaseField] for full list of default fields.
7777

@@ -224,4 +224,4 @@ class PostView(BaseModelView):
224224
cnt += 1
225225
return cnt
226226

227-
```
227+
```

docs/advanced/custom-field.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ the admin class
3131
This is simple example with SQLAlchemy backend
3232
```python
3333
from starlette_admin.contrib.sqla import Admin as BaseAdmin
34-
34+
3535
class Admin(BaseAdmin):
3636
def custom_render_js(self, request: Request) -> Optional[str]:
3737
return request.url_for("statics", path="js/custom_render.js")
38-
38+
3939
admin = Admin(engine)
4040
admin.add_view(...)
4141
```
@@ -50,7 +50,7 @@ the admin class
5050
!!! note
5151
`fieldOptions` is your field as javascript object. Your field attributes is serialized into
5252
javascript object by using dataclass `asdict` function.
53-
53+
5454
* Then, set `render_function_key` value
5555

5656
```python
@@ -59,7 +59,7 @@ from dataclasses import dataclass
5959

6060
@dataclass
6161
class CustomField(BaseField):
62-
render_function_key: str = "mycustomkey"
62+
render_function_key: str = "mycustomkey"
6363
```
6464

6565
## Form
@@ -91,8 +91,8 @@ from dataclasses import dataclass
9191

9292
@dataclass
9393
class CustomField(BaseField):
94-
render_function_key: str = "mycustomkey"
95-
form_template: str = "forms/custom.html"
94+
render_function_key: str = "mycustomkey"
95+
form_template: str = "forms/custom.html"
9696
```
9797

9898
## Detail Page
@@ -115,12 +115,12 @@ from dataclasses import dataclass
115115

116116
@dataclass
117117
class CustomField(BaseField):
118-
render_function_key: str = "mycustomkey"
119-
form_template: str = "forms/custom.html"
118+
render_function_key: str = "mycustomkey"
119+
form_template: str = "forms/custom.html"
120120
display_template = "displays/custom.html"
121121
```
122122

123-
## Data processing
123+
## Data processing
124124

125125
For data processing you will need to override two functions:
126126

@@ -157,4 +157,4 @@ class CustomField(BaseField):
157157

158158

159159
!!! important
160-
Override `dict` function to get control of the options which is available in javascript.
160+
Override `dict` function to get control of the options which is available in javascript.

docs/alternatives.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
* [Flask-Admin:](https://github.com/flask-admin/flask-admin) Simple and extensible administrative interface framework for Flask. The main goal of this project is to provide similar tool for Starlette/FastApi.
44
* [FastApi-Admin:](https://github.com/fastapi-admin/fastapi-admin) A fast admin dashboard based on FastAPI and TortoiseORM.
5-
* [sqladmin:](https://github.com/aminalaee/sqladmin) SQLAlchemy Admin for FastAPI and Starlette
5+
* [sqladmin:](https://github.com/aminalaee/sqladmin) SQLAlchemy Admin for FastAPI and Starlette

docs/api/auth-provider.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
:::starlette_admin.auth.AuthProvider
1+
:::starlette_admin.auth.AuthProvider

docs/api/base-admin.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
:::starlette_admin.base.BaseAdmin
1+
:::starlette_admin.base.BaseAdmin

docs/api/fields.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
:::starlette_admin.fields.HasOne
2222
:::starlette_admin.fields.HasMany
2323
:::starlette_admin.fields.ListField
24-
:::starlette_admin.fields.CollectionField
24+
:::starlette_admin.fields.CollectionField

docs/api/views.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
:::starlette_admin.views.DropDown
33
:::starlette_admin.views.Link
44
:::starlette_admin.views.CustomView
5-
:::starlette_admin.views.BaseModelView
5+
:::starlette_admin.views.BaseModelView

docs/changelog.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2727
class Post:
2828
id: int
2929
title: str
30-
30+
3131
admin.add_view(ModelView(Post, icon="fa fa-blog", label = "Blog Posts"))
3232
```
3333

@@ -36,12 +36,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
3636
class Post:
3737
id: int
3838
title: str
39-
40-
39+
40+
4141
class PostView(ModelView, model=Post):
4242
icon = "fa fa-blog"
4343
label = "Blog Posts"
44-
44+
4545
admin.add_view(PostView)
4646
```
4747

@@ -58,7 +58,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5858
icon = "fa fa-home"
5959
path = "/home"
6060
template_path = "home.html"
61-
61+
6262
admin.add_view(HomeView)
6363
```
6464

@@ -83,14 +83,14 @@ These changes are inspired from *Flask-admin* and are introduced to help reduce
8383

8484
* Add `CollectionField`
8585
* Add `ListField`
86-
* Add support for [Odmantic](https://art049.github.io/odmantic/)
86+
* Add support for [Odmantic](https://art049.github.io/odmantic/)
8787
* Add support for datatables [responsive extensions](https://datatables.net/extensions/responsive/)
8888
!!! usage
8989
```python
9090
class MyModelView(ModelView):
9191
responsive_table = True
9292
```
93-
93+
9494
### Changed
9595

9696
* Move `SQLModel` to it own contrib package

docs/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* [MongoEngine](http://mongoengine.org/)
4646
* [ODMantic](http://mongoengine.org/)
4747
- Custom backend ([doc](https://jowilf.github.io/starlette-admin/advanced/base-model-view/), [example](https://github.com/jowilf/starlette-admin/tree/main/examples/custom-backend))
48-
48+
4949

5050
## Installation
5151

@@ -109,4 +109,4 @@ Access your admin interface in your browser at [http://localhost:8000/admin](htt
109109
- [flatpickr](https://flatpickr.js.org/)
110110
- [moment](http://momentjs.com/)
111111
- [jsoneditor](https://github.com/josdejong/jsoneditor)
112-
- [fontawesome](https://fontawesome.com/)
112+
- [fontawesome](https://fontawesome.com/)

docs/stylesheets/extra.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
:root > * {
22
--md-primary-fg-color: #0073BB;
33
--md-primary-fg-color--dark: #005c96;
4-
}
4+
}

docs/tutorial/authentication.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ from starlette_admin import CustomView
8282
from starlette.requests import Request
8383

8484
class ReportView(CustomView):
85-
85+
8686
def is_accessible(self, request: Request) -> bool:
8787
return "admin" in request.state.user_roles
8888
```
@@ -122,4 +122,3 @@ class PostView(ModelView):
122122
def can_delete(self, request: Request) -> bool:
123123
return "admin" in request.state.user_roles
124124
```
125-

docs/tutorial/configurations/admin.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Admin Configurations
1+
# Admin Configurations
22

33
Multiple options are available to customize your admin interface
44

@@ -30,4 +30,4 @@ admin = Admin(
3030
* `templates_dir`: Templates dir for customisation
3131
* `index_view`: CustomView to use for index page.
3232
* `auth_provider`: Authentication Provider
33-
* `middlewares`: Starlette middlewares
33+
* `middlewares`: Starlette middlewares

docs/tutorial/configurations/modelview.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ Two options are available to specify which fields can be sorted or searched.
7373
You can export your data from list page. The export options can be set per model and includes the following options:
7474

7575
* `export_fields`: List of fields to include in exports.
76-
* `export_types`: A list of available export filetypes. Available
76+
* `export_types`: A list of available export filetypes. Available
7777
exports are `['csv', 'excel', 'pdf', 'print']`. By default, All of them are activated by default.
7878

7979
!!! Example
8080
```Python
8181
from starlette_admin import ExportType
82-
82+
8383
class PostView(ModelView):
8484
export_fields = [Post.id, Post.content, Post.tags]
8585
export_types = [ExportType.CSV, ExportType.EXCEL]
@@ -91,7 +91,7 @@ The pagination options in the list page can be configured. The available options
9191

9292
* `page_size`: Default number of items to display in List page pagination.
9393
Default value is set to `10`.
94-
* `page_size_options`: Pagination choices displayed in List page. Default value is set to `[10, 25, 50, 100]`.
94+
* `page_size_options`: Pagination choices displayed in List page. Default value is set to `[10, 25, 50, 100]`.
9595
Use `-1`to display All
9696

9797

@@ -114,4 +114,4 @@ The template files are built using Jinja2 and can be completely overridden in th
114114
```Python
115115
class PostView(ModelView):
116116
detail_template = "post_detail.html"
117-
```
117+
```

0 commit comments

Comments
 (0)