February of 2022
Activism⚑
Feminism⚑
Privileges⚑
-
New: How to reduce online racism.
Add article How to reduce online racism by Mark Holden, a long essay with interesting tips and a lot of useful visualizations, I haven't checked the sources but it looks legit. (Thanks for the recommendation Laurie
:)
).
Coding⚑
Python⚑
asyncio⚑
-
New: Introduce PDM.
PDM is a modern Python package manager with PEP 582 support. It installs and manages packages in a similar way to npm that doesn't need to create a virtualenv at all!
-
New: Note that
pdm update
doesn't upgrade the constrains inpyproject.toml
. -
New: Add tutorial on how to use asyncio.
-
New: Version overriding now supports constrains.
Before you had to pin specific versions, which is not maintainable, now you can use constrains
[tool.pdm.overrides] asgiref = ">=3.2.10"
-
pdm update --dry-run --unconstrained
Pydantic Factories⚑
-
Correction: Correct the type hints of the factory.
Use
Any
class PersonFactory(ModelFactory[Any]): ...
FastAPI⚑
-
Probably you've introduced an ending
/
to the endpoint, so instead of asking for/my/endpoint
you tried to do/my/endpoint/
.
Feedparser⚑
Pytest⚑
-
Correction: Update the tmpdir_factory type hints.
You should now use
TempPathFactory
instead ofTempdirFactory
-
Correction: Use
pytest-freezegun
globally.Most of the tests work with frozen time, so it's better to freeze it by default and unfreeze it on the ones that actually need time to move.
To do that set in your
tests/conftest.py
a globally used fixture:if TYPE_CHECKING: from freezegun.api import FrozenDateTimeFactory @pytest.fixture(autouse=True) def frozen_time() -> Generator['FrozenDateTimeFactory', None, None]: """Freeze all tests time""" with freezegun.freeze_time() as freeze: yield freeze
-
New: Ignore a warning of a specific package.
In the
pyproject.toml
filterwarnings = [ "error", # Until https://github.com/ktosiek/pytest-freezegun/issues/35 is merged "ignore::DeprecationWarning:pytest_freezegun.*" ]
Python Snippets⚑
-
Warning messages are typically issued in situations where it is useful to alert the user of some condition in a program, where that condition (normally) doesn’t warrant raising an exception and terminating the program. For example, one might want to issue a warning when a program uses an obsolete module.
import warnings def f(): warnings.warn('Message', DeprecationWarning)
To test the function with pytest you can use
pytest.warns
:import warnings import pytest def test_warning(): with pytest.warns(UserWarning, match='my warning'): warnings.warn("my warning", UserWarning)
-
New: Parse XML file with beautifulsoup.
You need both
beautifulsoup4
andlxml
:bs = BeautifulSoup(requests.get(url), "lxml")
-
New: Get a traceback from an exception.
import traceback traceback_str = ''.join(traceback.format_tb(e.__traceback__))
DevOps⚑
Infrastructure as Code⚑
Ansible Snippets⚑
-
New: Speed up the stat module.
The
stat
module calculates the checksum and the md5 of the file in order to get the required data. If you just want to check if the file exists use:- name: Verify swapfile status stat: path: "{{ common_swapfile_location }}" get_checksum: no get_md5: no get_mime: no get_attributes: no register: swap_status changed_when: not swap_status.stat.exists
Continuous Integration⚑
Flakeheaven⚑
-
New: Deprecate flakeheaven in favour of flakeheaven.
It's a fork maintained by the community, instead of an absent code dictator.
Operative Systems⚑
Linux⚑
Github cli⚑
-
To manually trigger a workflow you need to first configure it to allow
workflow_dispatch
events.on: workflow_dispatch:
Then you can trigger the workflow with
gh workflow run {{ workflow_name }}
, where you can get theworkflow_name
withgh workflow list
Vim⚑
-
New: Delete a file inside vim.
:call delete(expand('%')) | bdelete!
Arts⚑
Board Gaming⚑
Regicide⚑
-
New: Player modifiers extension.
At the start of the game players can decide their suit, they will get a bonus on the played cards of their suit, and a penalization on the opposite suit. The opposite suits are:
- ♠ opposite of ♥
- ♣ opposite of ♦
The bonus depends on the level of the enemy being: