2021-06-16 Javascript + Python timer + dataprotectioncontrol + libera.chat + mypy 0.900 (TypeGuard) + redis/postgresql

Tuto javascript

Advanced Data Protection Control dataprotectioncontrol

tom-select

Python timer

libera.chat

All Python IRC notifications moved to Libera Chat #python-dev-notifs: GitHub pull request reviews, http://bugs.python.org issues and comments, and buildbot state changes. Thanks @EWDurbin

! Also, I left Freenode. I’m sad Visage somnolent, but there is now the brand new Libera Chat Visage souriant avec 3 cœurs!

mypy 0.900

TypeGuard

Mypy now supports defining user-defined functions that perform type narrowing, similar to isinstance .

Read PEP 647 for the details.

Here’s an example adapted from the PEP:

from typing_extensions import TypeGuard

def is_str_list(val: List[object]) -> TypeGuard[List[str]]:
    """Are all list items strings?"""
    return all(isinstance(x, str) for x in val)

def func(val: List[object]) -> None:
    if is_str_list(val):
        print(" ".join(val))  # OK

Since TypeGuard will be included in Python 3.10, which hasn’t been released yet, you will have to import it from a recent version of typing_extensions for now.

This was contributed by Guido van Rossum (PR 9865).

Hosted Documentation for Mypyc

We now have hosted user documentation for mypyc, the compiler we use to speed up mypy.

Mypyc is still experimental, but we are looking for early adopters.

Support for pyproject.toml

You can now use a pyproject.toml file instead of mypy.ini for mypy configuration. Here is an example from the documentation:

# mypy global options:

[tool.mypy]
python_version = "2.7"
warn_return_any = true
warn_unused_configs = true

# mypy per-module options:

[[tool.mypy.overrides]]
module = "mycode.foo.*"
disallow_untyped_defs = true

[[tool.mypy.overrides]]
module = "mycode.bar"
warn_return_any = false

[[tool.mypy.overrides]]
module = [
    "somelibrary",
    "some_other_library"
]
ignore_missing_imports = true

Do You Really Need Redis? How to Get Away with Just PostgreSQL

There’s a tried-and-true architecture that I’ve seen many times for supporting your web services and applications:

  • PostgreSQL for data storage

  • Redis for coordinating background job queues (and some limited atomic operations)

Redis is fantastic, but what if I told you that its most common use cases for this stack could actually be achieved using only PostgreSQL ?