Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Virashu committed Jul 25, 2024
1 parent 12983c5 commit 2ee5ef0
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
- name: Analyze the code with pylint
run: |
pylint $(git ls-files '*.py') > reports/pylint_report.txt || true
pylint -f json2 $(git ls-files '*.py') | jq '.statistics.score' > pylint_score.txt
pylint ./y > reports/pylint_report.txt || true
pylint -f json2 ./y | jq '.statistics.score' > pylint_score.txt
# Combine
- name: Combine results
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fail_fast: false
repos:
- repo: https://github.com/pycqa/isort
rev: 5.13.2
Expand Down
104 changes: 103 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ flask-wtf = "^1.2.1"
[tool.poetry.scripts]
start = "y.cli:main"

[tool.poetry.group.dev.dependencies]
pylint = "^3.2.6"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.pylint]
disable = ["missing-module-docstring", "missing-class-docstring", "missing-function-docstring"]
disable = [
"missing-module-docstring",
"missing-class-docstring",
"missing-function-docstring",
"import-error",
]

[tool.pyright]
typeCheckingMode = "strict"
Expand All @@ -31,3 +38,9 @@ reportImplicitOverride = true
reportDeprecated = true
reportAny = false
stubPath = "./typings"

[tool.isort]
atomic = true
profile = "black"
line_length = 88
skip_gitignore = true
1 change: 1 addition & 0 deletions typings/flask_wtf/csrf.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, TypeVar, Union, override

from flask import Blueprint, Flask
from werkzeug.exceptions import BadRequest
from wtforms import Field
Expand Down
11 changes: 5 additions & 6 deletions typings/flask_wtf/file.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from _typeshed import Incomplete
from typing import Any, Iterable, TypeAlias, override

from _typeshed import Incomplete

__all__ = (
"FileField",
"MultipleFileField",
Expand All @@ -13,11 +14,9 @@ __all__ = (
)

from werkzeug.datastructures import FileStorage
from wtforms import (
Field,
FileField as _FileField,
MultipleFileField as _MultipleFileField,
)
from wtforms import Field
from wtforms import FileField as _FileField
from wtforms import MultipleFileField as _MultipleFileField
from wtforms.form import BaseForm
from wtforms.validators import DataRequired

Expand Down
2 changes: 0 additions & 2 deletions typings/flask_wtf/form.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,13 @@ class FlaskForm(Form):
the method is ``POST``, ``PUT``, ``PATCH``, or ``DELETE``.
"""
...

def validate_on_submit(
self, extra_validators: dict[str, Sequence[Callable[..., bool]]] = ...
) -> bool:
"""Call :meth:`validate` only if the form is submitted.
This is a shortcut for ``form.is_submitted() and form.validate()``.
"""
...

def hidden_tag(self, *fields: str) -> Markup:
"""Render the form's hidden fields in one call.
Expand Down
1 change: 0 additions & 1 deletion y/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import flask
import flask_login
import werkzeug

from flask.typing import ResponseReturnValue

from .database import database
Expand Down
2 changes: 2 additions & 0 deletions y/database/db_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
SqlAlchemyBase = orm.declarative_base()


# pylint: disable=too-few-public-methods
class SessionFactory:
# pylint: disable=unsubscriptable-object # (sessionmaker is Generic)
_factory: orm.sessionmaker[orm.Session] | None = None

def __init__(self, db_file: str) -> None:
Expand Down
1 change: 1 addition & 0 deletions y/database/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from .db_session import SqlAlchemyBase


# pylint: disable=too-few-public-methods # (ORM mapping class)
class Post(SqlAlchemyBase):
__tablename__ = "posts"

Expand Down
7 changes: 4 additions & 3 deletions y/form_fields.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import Any, Callable, Self, Sequence

from _typeshed import Incomplete
from wtforms import PasswordField, StringField
from wtforms.form import BaseForm
from wtforms.meta import DefaultMeta
from wtforms.validators import DataRequired
from _typeshed import Incomplete


class RequiredStringField(StringField):
Expand All @@ -13,13 +14,14 @@ class RequiredStringField(StringField):

data: str # type: ignore

# pylint: disable=too-many-arguments # (external class)
def __init__(
self,
label: str | None = None,
validators: tuple[Incomplete[Incomplete, Self], ...] | list[Any] | None = None,
filters: Sequence[Incomplete] = (),
description: str = "",
id: str | None = None,
id: str | None = None, # pylint: disable=redefined-builtin # (external class)
default: str | Callable[[], str] | None = None,
widget: Incomplete[Self] | None = None,
render_kw: dict[str, Any] | None = None,
Expand Down Expand Up @@ -49,5 +51,4 @@ def __init__(


class RequiredPasswordField(RequiredStringField, PasswordField):

data: str # type: ignore
3 changes: 2 additions & 1 deletion y/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import flask_wtf
import wtforms
from .form_fields import RequiredStringField, RequiredPasswordField

from .form_fields import RequiredPasswordField, RequiredStringField
from .utils import hash_string


Expand Down

0 comments on commit 2ee5ef0

Please sign in to comment.