make file improvements and some pylint cleanup

This commit is contained in:
Balakrishnan Balasubramanian 2024-04-03 09:52:45 -04:00
parent cb15ec15e4
commit e853cfe62d
5 changed files with 19 additions and 11 deletions

View File

@ -1,10 +1,11 @@
# Needs python3 >= 3.9, sed, git for build, docker for tests
.PHONY: build
build: clean
python3 -m pip install -r requirements.txt --no-compile --target build
cp -r mail4one/ build/
sed -i "s/DEVELOMENT/$(shell scripts/get_version.sh)/" build/mail4one/version.py
find build -name "*.pyi" -o -name "py.typed" | xargs -I typefile rm typefile
rm -rf build/bin
rm -rf build/bin build/aiosmtpd/{docs,tests,qa}
rm -rf build/mail4one/__pycache__
rm -rf build/*.dist-info
python3 -m zipapp \
@ -13,10 +14,12 @@ build: clean
--main mail4one.server:main \
--compress build
.PHONY: clean
clean:
rm -rf build
rm -rf mail4one.pyz
.PHONY: docker-tests
docker-tests:
docker run --pull=always -v `pwd`:/app -w /app --rm python:3.11-alpine sh scripts/runtests.sh
docker run --pull=always -v `pwd`:/app -w /app --rm python:3.10-alpine sh scripts/runtests.sh
@ -31,24 +34,31 @@ docker-tests:
requirements.txt: Pipfile.lock
pipenv requirements > requirements.txt
.PHONY: format
format:
black mail4one/*py tests/*py
.PHONY: build-dev
build-dev: requirements.txt build
.PHONY: setup
setup:
pipenv install
.PHONY: cleanup
cleanup:
pipenv --rm
.PHONY: update
update:
rm requirements.txt Pipfile.lock
pipenv update
pipenv requirements > requirements.txt
.PHONY: shell
shell:
MYPYPATH=`pipenv --venv`/lib/python3.11/site-packages pipenv shell
MYPYPATH=$(shell ls -d `pipenv --venv`/lib/python3*/site-packages) pipenv shell
.PHONY: test
test:
pipenv run python -m unittest discover

View File

@ -1,4 +1,5 @@
import json
"""Module for parsing mail4one config.json"""
import re
import logging
from typing import Callable, Union, Optional

View File

@ -3,14 +3,14 @@ import contextlib
import contextvars
import logging
import ssl
import random
from typing import Optional
from asyncio import StreamReader, StreamWriter
from dataclasses import dataclass
from pathlib import Path
from .config import User
from .pwhash import parse_hash, check_pass, PWInfo
from asyncio import StreamReader, StreamWriter
import random
from typing import Optional
from .poputils import (
InvalidCommand,
@ -313,12 +313,10 @@ async def start_session() -> None:
assert state().mbox
await transaction_stage()
logger.info(f"User:{state().username} done")
except ClientDisconnected as c:
except ClientDisconnected:
logger.info("Client disconnected")
pass
except ClientQuit:
logger.info("Client QUIT")
pass
except ClientError as c:
write(err("Something went wrong"))
logger.error(f"Unexpected client error: {c}")

View File

@ -4,6 +4,7 @@ import ssl
from argparse import ArgumentParser
from pathlib import Path
from getpass import getpass
from typing import Optional, Union
from .smtp import create_smtp_server_starttls, create_smtp_server
from .pop3 import create_pop_server
@ -11,7 +12,6 @@ from .version import VERSION
from . import config
from . import pwhash
from typing import Optional, Union
def create_tls_context(certfile, keyfile) -> ssl.SSLContext:

View File

@ -6,7 +6,6 @@ import shutil
from functools import partial
from pathlib import Path
from typing import Callable, Optional
from . import config
from email.message import Message
import email.policy
from email.generator import BytesGenerator