chore: make style, upgrade deps, fix ci error and update changelog
This commit is contained in:
parent
095eb48196
commit
dc020358b6
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -18,6 +18,9 @@ jobs:
|
||||
POSTGRES_PASSWORD: 123456
|
||||
POSTGRES_USER: postgres
|
||||
options: --health-cmd=pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
||||
steps:
|
||||
- name: Start MySQL
|
||||
run: sudo systemctl start mysql.service
|
||||
@ -30,7 +33,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install and configure Poetry
|
||||
run: |
|
||||
pip install -U pip poetry
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
### 0.8.0 (unreleased)
|
||||
|
||||
- Correct the click import. (#360)
|
||||
- Improve CLI help text and output. (#355)
|
||||
- Fix mysql drop unique index raises OperationalError. (#346)
|
||||
|
||||
**Upgrade note:**
|
||||
|
5
Makefile
5
Makefile
@ -23,7 +23,10 @@ _check:
|
||||
@black --check $(black_opts) $(checkfiles) || (echo "Please run 'make style' to auto-fix style issues" && false)
|
||||
@ruff check $(checkfiles)
|
||||
@mypy $(checkfiles)
|
||||
ifneq ($(shell python -c 'import sys;is_py38=sys.version_info<(3,9);rc=int(is_py38);sys.exit(rc)'),)
|
||||
# Run bandit with Python3.9+, as the `usedforsecurity=...` parameter of `hashlib.new` is only added from Python 3.9 onwards.
|
||||
@bandit -r aerich
|
||||
endif
|
||||
check: deps _check
|
||||
|
||||
test: deps
|
||||
@ -39,7 +42,7 @@ test_postgres:
|
||||
$(py_warn) TEST_DB="postgres://postgres:$(POSTGRES_PASS)@$(POSTGRES_HOST):$(POSTGRES_PORT)/test_\{\}" pytest -vv -s
|
||||
|
||||
_testall: test_sqlite test_postgres test_mysql
|
||||
testall: deps _test_all
|
||||
testall: deps _testall
|
||||
|
||||
build: deps
|
||||
@poetry build
|
||||
|
@ -37,7 +37,9 @@ async def cli(ctx: Context, config, app) -> None:
|
||||
if invoked_subcommand != "init":
|
||||
config_path = Path(config)
|
||||
if not config_path.exists():
|
||||
raise UsageError("You need to run `aerich init` first to create the config file.", ctx=ctx)
|
||||
raise UsageError(
|
||||
"You need to run `aerich init` first to create the config file.", ctx=ctx
|
||||
)
|
||||
content = config_path.read_text()
|
||||
doc: dict = tomlkit.parse(content)
|
||||
try:
|
||||
@ -56,7 +58,9 @@ async def cli(ctx: Context, config, app) -> None:
|
||||
ctx.obj["command"] = command
|
||||
if invoked_subcommand != "init-db":
|
||||
if not Path(location, app).exists():
|
||||
raise UsageError("You need to run `aerich init-db` first to initialize the database.", ctx=ctx)
|
||||
raise UsageError(
|
||||
"You need to run `aerich init-db` first to initialize the database.", ctx=ctx
|
||||
)
|
||||
await command.init()
|
||||
|
||||
|
||||
|
@ -192,7 +192,7 @@ class Migrate:
|
||||
ret: list = []
|
||||
|
||||
def index_hash(self) -> str:
|
||||
h = hashlib.new("MD5", usedforsecurity=False)
|
||||
h = hashlib.new("MD5", usedforsecurity=False) # type:ignore[call-arg]
|
||||
h.update(
|
||||
self.index_name(cls.ddl.schema_generator, model).encode()
|
||||
+ self.__class__.__name__.encode()
|
||||
|
@ -9,7 +9,7 @@ MAX_APP_LENGTH = 100
|
||||
class Aerich(Model):
|
||||
version = fields.CharField(max_length=MAX_VERSION_LENGTH)
|
||||
app = fields.CharField(max_length=MAX_APP_LENGTH)
|
||||
content = fields.JSONField(encoder=encoder, decoder=decoder)
|
||||
content: dict = fields.JSONField(encoder=encoder, decoder=decoder)
|
||||
|
||||
class Meta:
|
||||
ordering = ["-id"]
|
||||
|
895
poetry.lock
generated
895
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -22,8 +22,8 @@ asyncmy = { version = "^0.2.9", optional = true, allow-prereleases = true }
|
||||
pydantic = "^2.0"
|
||||
dictdiffer = "*"
|
||||
tomlkit = "*"
|
||||
|
||||
asyncclick = "^8.1.7.2"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
ruff = "*"
|
||||
isort = "*"
|
||||
@ -64,6 +64,7 @@ asyncio_mode = 'auto'
|
||||
|
||||
[tool.mypy]
|
||||
pretty = true
|
||||
python_version = "3.8"
|
||||
ignore_missing_imports = true
|
||||
|
||||
[tool.ruff.lint]
|
||||
|
@ -75,7 +75,7 @@ class Product(Model):
|
||||
class Config(Model):
|
||||
label = fields.CharField(max_length=200)
|
||||
key = fields.CharField(max_length=20)
|
||||
value = fields.JSONField()
|
||||
value: dict = fields.JSONField()
|
||||
status: Status = fields.IntEnumField(Status)
|
||||
user: fields.ForeignKeyRelation[User] = fields.ForeignKeyField(
|
||||
"models.User", description="User"
|
||||
|
@ -67,5 +67,5 @@ class Product(Model):
|
||||
class Config(Model):
|
||||
label = fields.CharField(max_length=200)
|
||||
key = fields.CharField(max_length=20)
|
||||
value = fields.JSONField()
|
||||
value: dict = fields.JSONField()
|
||||
status: Status = fields.IntEnumField(Status, default=Status.on)
|
||||
|
@ -66,7 +66,7 @@ class Product(Model):
|
||||
class Config(Model):
|
||||
label = fields.CharField(max_length=200)
|
||||
key = fields.CharField(max_length=20)
|
||||
value = fields.JSONField()
|
||||
value: dict = fields.JSONField()
|
||||
status: Status = fields.IntEnumField(Status, default=Status.on)
|
||||
|
||||
class Meta:
|
||||
|
@ -819,7 +819,7 @@ def test_migrate(mocker: MockerFixture):
|
||||
- alter default: Config.status
|
||||
- rename column: Product.image -> Product.pic
|
||||
"""
|
||||
mocker.patch("click.prompt", side_effect=(True,))
|
||||
mocker.patch("asyncclick.prompt", side_effect=(True,))
|
||||
|
||||
models_describe = get_models_describe("models")
|
||||
Migrate.app = "models"
|
||||
|
Loading…
x
Reference in New Issue
Block a user