Skip to content

Commit

Permalink
3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
gitcarbs committed Sep 19, 2024
1 parent ae845fd commit 912f145
Show file tree
Hide file tree
Showing 49 changed files with 215 additions and 155 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: guillotina

on: [push]
on: [push, workflow_dispatch]

jobs:

Expand All @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.10.14]

steps:
- name: Checkout the repository
Expand All @@ -24,8 +24,8 @@ jobs:
run: |
pip install click==8.0.4
pip install flake8==3.7.7
pip install mypy==0.720
pip install mypy-zope==0.2.0
pip install mypy==1.0.1
pip install mypy-zope==0.3.2
pip install black==19.10b0
- name: Run pre-checks
run: |
Expand All @@ -38,7 +38,7 @@ jobs:

strategy:
matrix:
python-version: [3.8]
python-version: [3.10.14]
database: ["DUMMY", "postgres"]
db_schema: ["custom", "public"]
exclude:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
CHANGELOG
=========

5.5.1 (2024-09-10)
-------------------
- Python 3.10

5.5.0 (2024-05-10)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.5.0
5.5.1
8 changes: 4 additions & 4 deletions contrib-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ aiosmtplib==1.0.6
pre-commit==1.18.2
flake8==3.7.7
codecov==2.1.13
mypy==0.720
mypy-zope==0.2.0
mypy==1.10.1
mypy-zope==1.0.5
black==19.10b0
isort==4.3.21
emcache==0.4.1
pymemcache==3.4.0
emcache==1.3.0
pymemcache==4.0.0
6 changes: 3 additions & 3 deletions guillotina/api/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ async def __call__(self, check_security: bool = True):

obj = await post( # type: ignore
context=self.context,
data=data,
_id=new_id,
user=user,
data=data, # type: ignore
_id=new_id, # type: ignore
user=user, # type: ignore
type_=type_,
request=self.request,
check_security=check_security,
Expand Down
2 changes: 1 addition & 1 deletion guillotina/api/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def __call__(self):
}
jwt_token = jwt.encode(
data, app_settings["jwt"]["secret"], algorithm=app_settings["jwt"]["algorithm"]
).decode("utf-8")
)

await notify(UserRefreshToken(user, jwt_token))

Expand Down
7 changes: 3 additions & 4 deletions guillotina/async_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@


class QueueUtility(object):
def __init__(self, settings=None, loop=None):
def __init__(self, settings=None):
self._queue = None
self._loop = loop
self._exceptions = False
self._total_queued = 0

@property
def queue(self):
if self._queue is None:
self._queue = asyncio.Queue(loop=self._loop)
self._queue = asyncio.Queue()
return self._queue

async def initialize(self, app=None):
Expand Down Expand Up @@ -126,7 +125,7 @@ async def run(self):


class AsyncJobPool:
def __init__(self, settings=None, loop=None):
def __init__(self, settings=None):
settings = settings or {"max_size": 5}
self._loop = None
self._running = []
Expand Down
4 changes: 1 addition & 3 deletions guillotina/auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,5 @@ def authenticate_user(userid, data=None, timeout=60 * 60 * 1):
data.update(
{"iat": datetime.utcnow(), "exp": datetime.utcnow() + timedelta(seconds=timeout), "id": userid}
)
jwt_token = jwt.encode(
data, app_settings["jwt"]["secret"], algorithm=app_settings["jwt"]["algorithm"]
).decode("utf-8")
jwt_token = jwt.encode(data, app_settings["jwt"]["secret"], algorithm=app_settings["jwt"]["algorithm"])
return jwt_token, data
7 changes: 3 additions & 4 deletions guillotina/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ def run_command(self, settings=None, loop=None):
run_func(app, settings)

def __run_with_monitor(self, app, settings):
loop = self.get_loop()
with aiomonitor.start_monitor(loop=loop):
with aiomonitor.start_monitor():
self.__run(app, settings)

def __run(self, app, settings):
Expand Down Expand Up @@ -204,7 +203,7 @@ async def cleanup(self, app):
await app.on_cleanup.send(app)
except Exception:
logger.warning("Unhandled error cleanup tasks", exc_info=True)
for task in asyncio.Task.all_tasks():
for task in asyncio.all_tasks():
if task.done():
continue
if "cleanup" in task._coro.__qualname__:
Expand Down Expand Up @@ -237,7 +236,7 @@ def signal_handler(self, signal, frame):
def make_app(self, settings):
signal.signal(signal.SIGINT, self.signal_handler)
loop = self.get_loop()
return loop.run_until_complete(make_app(settings=settings, loop=loop))
return loop.run_until_complete(make_app(settings=settings))

def get_parser(self):
parser = argparse.ArgumentParser(description=self.description)
Expand Down
3 changes: 2 additions & 1 deletion guillotina/commands/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def run(self, arguments, settings, app):
host = arguments.host or settings.get("host", "0.0.0.0")
log_format = settings.get("access_log_format", AccessLogger.LOG_FORMAT)
try:
web.run_app(app, host=host, port=port, access_log_format=log_format)
loop = asyncio.get_event_loop()
web.run_app(app, host=host, port=port, access_log_format=log_format, loop=loop)
except asyncio.CancelledError:
# server shut down, we're good here.
pass
2 changes: 1 addition & 1 deletion guillotina/component/globalregistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __init__(self, parent, name):


@implementer(IComponentLookup)
class GlobalComponents(Components):
class GlobalComponents(Components): # type: ignore
def _init_registries(self):
self.adapters = GuillotinaAdapterRegistry(self, "adapters")
self.utilities = GuillotinaAdapterRegistry(self, "utilities")
Expand Down
2 changes: 1 addition & 1 deletion guillotina/configure/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def __init__(self, etype, evalue):
self.etype, self.evalue = etype, evalue

def __str__(self): # pragma NO COVER
return "%s: %s\n in:\n %s" % (self.etype, self.evalue)
return "%s:\n in:\n %s" % (self.etype, self.evalue)


##############################################################################
Expand Down
16 changes: 7 additions & 9 deletions guillotina/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,13 @@ def uuid(self):
"""
return self.__uuid__

def __init__(self, id: str = None) -> None:
def __init__(self, id: str = None) -> None: # type: ignore
if id is not None:
self.__name__ = id
super(Resource, self).__init__()

def __repr__(self):
"""
"""
""" """
path = "/".join(get_physical_path(self))
return "< {type} at {path} by {mem} >".format(type=self.type_name, path=path, mem=id(self))

Expand Down Expand Up @@ -389,8 +388,7 @@ async def async_values(self, suppress_events=False) -> AsyncIterator[Tuple[Resou

@configure.contenttype(type_name="Container", schema=IContainer)
class Container(Folder):
"""
"""
""" """

async def install(self):
# Creating and registering a local registry
Expand Down Expand Up @@ -424,12 +422,12 @@ class StaticDirectory(dict):
Using dict makes this a simple container so traversing works
"""

def __init__(self, file_path: pathlib.Path, base_path: pathlib.Path = None) -> None:
def __init__(self, file_path: pathlib.Path, base_path: pathlib.Path = None) -> None: # type: ignore
self.file_path = file_path
if base_path is None:
self.base_path = file_path
else:
self.base_path = base_path
self.base_path = base_path # type: ignore

def __getitem__(self, filename):
path = pathlib.Path(os.path.join(self.file_path.absolute(), filename))
Expand Down Expand Up @@ -571,7 +569,7 @@ async def create_content(type_, **kw) -> IResource:
@profilable
async def create_content_in_container(
parent: Folder, type_: str, id_: str, request: IRequest = None, check_security=True, **kw
) -> Resource:
) -> Resource: # type: ignore
"""Utility to create a content.
This method is the one to use to create content.
Expand Down Expand Up @@ -656,7 +654,7 @@ async def get_all_behaviors(content, create=False, load=True, preload_only=False
annotation_data = await txn.get_annotations(content, list(data_keys))
for inst in instances:
key = getattr(inst, "__annotations_data_key__", None)
if key and key in annotation_data:
if annotation_data and key and key in annotation_data:
content.__gannotations__[key] = annotation_data[key]
if preload_only:
return []
Expand Down
4 changes: 2 additions & 2 deletions guillotina/contentapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def get_transaction(self) -> ITransaction:
task_vars.txn.set(self._active_txn)
return self._active_txn

async def create(self, payload: dict, in_: IResource = None) -> IResource:
async def create(self, payload: dict, in_: IResource = None) -> IResource: # type: ignore
await self.get_transaction()
if in_ is None:
in_ = self.db
Expand All @@ -70,7 +70,7 @@ async def json():
path = path[len(container_url or "") :]
return await navigate_to(in_, path.strip("/")) # type: ignore

async def get(self, path: str, in_: IResource = None) -> typing.Optional[IResource]:
async def get(self, path: str, in_: IResource = None) -> typing.Optional[IResource]: # type: ignore
await self.get_transaction()
if in_ is None:
in_ = self.db
Expand Down
2 changes: 1 addition & 1 deletion guillotina/contrib/cache/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async def get(self, **kwargs):
return obj

@profilable
async def set(self, value, keyset: List[Dict[str, Any]] = None, **kwargs):
async def set(self, value, keyset: List[Dict[str, Any]] = None, **kwargs): # type: ignore
if self._utility is None:
return
if keyset is None:
Expand Down
11 changes: 5 additions & 6 deletions guillotina/contrib/mailer/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ async def send(self, sender, recipients, message):

@implementer(IMailer)
class MailerUtility:
def __init__(self, settings=None, loop=None):
def __init__(self, settings=None):
self._settings = settings or {}
self._endpoints = {}
self.loop = loop

@property
def settings(self):
Expand Down Expand Up @@ -201,8 +200,8 @@ async def finalize(self):

@implementer(IMailer)
class PrintingMailerUtility(MailerUtility):
def __init__(self, settings=None, loop=None):
self._queue = asyncio.Queue(loop=loop)
def __init__(self, settings=None):
self._queue = asyncio.Queue()
self._settings = settings or {}

async def _send(self, sender, recipients, message, endpoint_name="default"):
Expand All @@ -211,8 +210,8 @@ async def _send(self, sender, recipients, message, endpoint_name="default"):

@implementer(IMailer)
class TestMailerUtility(MailerUtility):
def __init__(self, settings=None, loop=None):
self._queue = asyncio.Queue(loop=loop)
def __init__(self, settings=None):
self._queue = asyncio.Queue()
self.mail = []

async def send(
Expand Down
2 changes: 1 addition & 1 deletion guillotina/contrib/memcached/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def __init__(self, operation: str):
labels={"type": operation},
error_mappings={
"timeout": asyncio.TimeoutError,
"cancelled": asyncio.CancelledError,
"cancelled": asyncio.CancelledError, # type: ignore
}, # type: ignore
)

Expand Down
6 changes: 3 additions & 3 deletions guillotina/contrib/pubsub/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@


class PubSubUtility:
def __init__(self, settings=None, loop=None):
self._loop = loop
def __init__(self, settings=None):
self._settings = settings
self._subscribers = {}
self._initialized = False
Expand Down Expand Up @@ -43,8 +42,9 @@ async def initialize(self, app=None):
@backoff.on_exception(backoff.expo, (OSError,), max_time=30, max_tries=4)
async def _connect(self):
klass = resolve_dotted_name(self._settings["driver"])
loop = asyncio.get_event_loop()
self._driver = await klass.get_driver()
await self._driver.initialize(self._loop)
await self._driver.initialize(loop)
self._initialized = True

async def finalize(self, app):
Expand Down
8 changes: 7 additions & 1 deletion guillotina/db/cache/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ async def get(self, oid=None, container=None, id=None, variant=None):
raise NotImplemented()

async def set(
self, value, keyset: List[Dict[str, Any]] = None, oid=None, container=None, id=None, variant=None
self,
value,
keyset: List[Dict[str, Any]] = None,
oid=None,
container=None,
id=None,
variant=None, # type: ignore
):
"""
Use params to build cache key
Expand Down
8 changes: 7 additions & 1 deletion guillotina/db/cache/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ async def get(self, **kwargs):
return None

async def set(
self, value, keyset: List[Dict[str, Any]] = None, oid=None, container=None, id=None, variant=None
self,
value,
keyset: List[Dict[str, Any]] = None,
oid=None,
container=None,
id=None,
variant=None, # type: ignore
):
...

Expand Down
2 changes: 1 addition & 1 deletion guillotina/db/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class DeleteStorageException(Exception):
"""
Failed to delete a storage instance.
"""
"""
Loading

0 comments on commit 912f145

Please sign in to comment.