Week 2 – Modernization of Portage

Week 2 – Modernization of Portage

It is the second week of coding period and it has been a productive one. It started according to the  plans and diverged in the second half for the good. The first half was towards type annotation and the second half was dummy_threading deprecation.

Type annotation

In the words of Sam, my mentor, “I’d considere a GSOC project complete if some 50% of the  codebase is just type annotated”. Many portage developers were excited when we were talking  about adding type hints and docstrings.

Adding type hints and tidying up the codebase will also give me more exposure to the underlying functions. So, we decided, this week I’ll do type annotations.

Deciding on the type hints style

Python 3.9 adds a simpler “native” style type annotation, but portage has a minimum supported python version of 3.7.


# Python 3.7 style
a: typing.Optional[typing.List[str]] = None
b: typing.Dict[int] = {}

# Python 3.9 style
a: list[str] | None = None
b: dict[int] = {}

We can see that the 3.9 style is arguably more readable and we don’t have to import the typing module.

There is talk on increasing portage’s MSV to python 3.9, but till that is accepted, we decided to stick with python 3.7 style type annotations.

So, I added some type annotations and docstrings. Sam reviewed them and suggested a few  changes. After making the necessary changes, the pull request was merged. It can be found here. Portage’s need of type hints and docstrings can be felt by @ajakk’s comment here

dummy_threading deprecation

dummy_threading existed in python as threading was not stabilied in a few platforms. As I said in the first blog post, portage has to work on many platforms and different architectures. So, portage
had to take into account of the cases where threading might not be available.

But, things have been stabilized and from python version 3.7, dummy_threading is deprecated. Since portage’s MSV is python 3.7 we decided to remove all dummy_threading related

I removed everything related to dummy_threading and updated the tests according to the changed code. It took some 8 commits. I squashed everything and sent a pull request to GitHub. It can be found here Sam checked it once and it was held for some time to see if someone finds a mistake. Sam also said he wanted to get a look one more time with a fresh set of eyes. It was merged shortly.


TLDR, I sent two pull requests and both are merged

  • The first one with some type hints and docstrings.
  • The second one where all code related to dummy_threading is removed.

So, that marks the end of week two. Next week’s work probably is towards more type annotations and some minor improvements. I’ll keep you posted. Until then, take care!

This entry was posted in 2023 GSoC, Modernization of Portage with C++ and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.