diff --git a/.python-version b/.python-version
new file mode 100644
index 0000000000..2c0733315e
--- /dev/null
+++ b/.python-version
@@ -0,0 +1 @@
+3.11
diff --git a/bin/yunohost b/bin/yunohost
index 3f985e6e78..9dd7cee13f 100755
--- a/bin/yunohost
+++ b/bin/yunohost
@@ -1,4 +1,22 @@
-#! /usr/bin/python3
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
import os
import sys
diff --git a/bin/yunohost-api b/bin/yunohost-api
index 9f4d5eb262..cb4e0be147 100755
--- a/bin/yunohost-api
+++ b/bin/yunohost-api
@@ -1,4 +1,22 @@
-#! /usr/bin/python3
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
import argparse
import yunohost
diff --git a/bin/yunohost-portal-api b/bin/yunohost-portal-api
index 66751e66fe..690c7c576e 100755
--- a/bin/yunohost-portal-api
+++ b/bin/yunohost-portal-api
@@ -1,5 +1,22 @@
-#! /usr/bin/python3
-# -*- coding: utf-8 -*-
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
import argparse
import yunohost
diff --git a/bin/yunomdns b/bin/yunomdns
index da9233045f..2ab89f7075 100755
--- a/bin/yunomdns
+++ b/bin/yunomdns
@@ -1,4 +1,22 @@
#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
"""
Pythonic declaration of mDNS .local domains for YunoHost
diff --git a/bin/yunopaste b/bin/yunopaste
index f6bdecae2f..72c18dc3e0 100755
--- a/bin/yunopaste
+++ b/bin/yunopaste
@@ -1,4 +1,22 @@
#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
import sys
import requests
diff --git a/doc/generate_api_doc.py b/doc/generate_api_doc.py
index bb5f1df298..be8ae4f358 100644
--- a/doc/generate_api_doc.py
+++ b/doc/generate_api_doc.py
@@ -1,19 +1,22 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-""" License
- Copyright (C) 2013 YunoHost
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
- You should have received a copy of the GNU Affero General Public License
- along with this program; if not, see http://www.gnu.org/licenses
-"""
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
"""
Generate JSON specification files API
diff --git a/doc/generate_bash_completion.py b/doc/generate_bash_completion.py
index 460447ab17..18e27aa9d4 100644
--- a/doc/generate_bash_completion.py
+++ b/doc/generate_bash_completion.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
"""
Simple automated generation of a bash_completion file
for yunohost command from the actionsmap.
diff --git a/doc/generate_configpanel_and_formoptions_doc.py b/doc/generate_configpanel_and_formoptions_doc.py
index 156a769fc3..f31891b240 100644
--- a/doc/generate_configpanel_and_formoptions_doc.py
+++ b/doc/generate_configpanel_and_formoptions_doc.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import ast
import datetime
import subprocess
diff --git a/doc/generate_helper_doc.py b/doc/generate_helper_doc.py
index c4978863a7..7487c5f850 100644
--- a/doc/generate_helper_doc.py
+++ b/doc/generate_helper_doc.py
@@ -1,4 +1,22 @@
-#!/usr/env/python3
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
import sys
import os
diff --git a/doc/generate_json_schema.py b/doc/generate_json_schema.py
index 1abf88915f..06a8c7f76f 100644
--- a/doc/generate_json_schema.py
+++ b/doc/generate_json_schema.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
from yunohost.utils.configpanel import ConfigPanelModel
diff --git a/doc/generate_manpages.py b/doc/generate_manpages.py
index 782dd8a90a..848fd245c8 100644
--- a/doc/generate_manpages.py
+++ b/doc/generate_manpages.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
"""
Inspired by yunohost_completion.py (author: Christophe Vuillot)
=======
diff --git a/doc/generate_resource_doc.py b/doc/generate_resource_doc.py
index 300cf74bbf..f10848a666 100644
--- a/doc/generate_resource_doc.py
+++ b/doc/generate_resource_doc.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import ast
import datetime
import subprocess
diff --git a/maintenance/autofix_locale_format.py b/maintenance/autofix_locale_format.py
index 5fa34ad5ec..f6f7002ac0 100644
--- a/maintenance/autofix_locale_format.py
+++ b/maintenance/autofix_locale_format.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import os
import re
import json
diff --git a/maintenance/missing_i18n_keys.py b/maintenance/missing_i18n_keys.py
index 75426995f1..c89c898c0a 100644
--- a/maintenance/missing_i18n_keys.py
+++ b/maintenance/missing_i18n_keys.py
@@ -1,4 +1,22 @@
-# -*- coding: utf-8 -*-
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
import toml
import os
diff --git a/src/__init__.py b/src/__init__.py
index 7eb4f16cf9..c567e3a1dc 100644
--- a/src/__init__.py
+++ b/src/__init__.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
diff --git a/src/app.py b/src/app.py
index 5c00a15bcd..c457cdb087 100644
--- a/src/app.py
+++ b/src/app.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
diff --git a/src/app_catalog.py b/src/app_catalog.py
index 2f3076eed2..f507ed7719 100644
--- a/src/app_catalog.py
+++ b/src/app_catalog.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import re
import hashlib
diff --git a/src/authenticators/ldap_admin.py b/src/authenticators/ldap_admin.py
index ac08980da0..5851499099 100644
--- a/src/authenticators/ldap_admin.py
+++ b/src/authenticators/ldap_admin.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import jwt
import os
import logging
diff --git a/src/authenticators/ldap_ynhuser.py b/src/authenticators/ldap_ynhuser.py
index 98c8547246..f7bdc20f32 100644
--- a/src/authenticators/ldap_ynhuser.py
+++ b/src/authenticators/ldap_ynhuser.py
@@ -1,4 +1,22 @@
-# -*- coding: utf-8 -*-
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
import time
import jwt
diff --git a/src/backup.py b/src/backup.py
index 9fd3a266bb..b0cba0e9f6 100644
--- a/src/backup.py
+++ b/src/backup.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import re
import json
diff --git a/src/certificate.py b/src/certificate.py
index eb33b797e0..fdc38e642a 100644
--- a/src/certificate.py
+++ b/src/certificate.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import sys
import shutil
diff --git a/src/diagnosers/00-basesystem.py b/src/diagnosers/00-basesystem.py
index 65e78783f9..e8141926cc 100644
--- a/src/diagnosers/00-basesystem.py
+++ b/src/diagnosers/00-basesystem.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import json
import subprocess
diff --git a/src/diagnosers/10-ip.py b/src/diagnosers/10-ip.py
index 09199fb00e..ea346b8b21 100644
--- a/src/diagnosers/10-ip.py
+++ b/src/diagnosers/10-ip.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import re
import os
import random
diff --git a/src/diagnosers/12-dnsrecords.py b/src/diagnosers/12-dnsrecords.py
index e6959898f2..4c6d5e8a8d 100644
--- a/src/diagnosers/12-dnsrecords.py
+++ b/src/diagnosers/12-dnsrecords.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import re
import logging
diff --git a/src/diagnosers/14-ports.py b/src/diagnosers/14-ports.py
index b849273f20..07cc79e19c 100644
--- a/src/diagnosers/14-ports.py
+++ b/src/diagnosers/14-ports.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
from typing import List
diff --git a/src/diagnosers/21-web.py b/src/diagnosers/21-web.py
index 02b7052944..e3659a6411 100644
--- a/src/diagnosers/21-web.py
+++ b/src/diagnosers/21-web.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import random
import requests
diff --git a/src/diagnosers/24-mail.py b/src/diagnosers/24-mail.py
index 7ca5821476..51bff895ea 100644
--- a/src/diagnosers/24-mail.py
+++ b/src/diagnosers/24-mail.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import dns.resolver
import re
diff --git a/src/diagnosers/30-services.py b/src/diagnosers/30-services.py
index ee63f4559b..47169c1a73 100644
--- a/src/diagnosers/30-services.py
+++ b/src/diagnosers/30-services.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
from typing import List
diff --git a/src/diagnosers/50-systemresources.py b/src/diagnosers/50-systemresources.py
index 536d8fd71a..71a26ea5de 100644
--- a/src/diagnosers/50-systemresources.py
+++ b/src/diagnosers/50-systemresources.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import psutil
import datetime
diff --git a/src/diagnosers/70-regenconf.py b/src/diagnosers/70-regenconf.py
index c6317d4fc0..9b1664ea7e 100644
--- a/src/diagnosers/70-regenconf.py
+++ b/src/diagnosers/70-regenconf.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import re
from typing import List
diff --git a/src/diagnosers/80-apps.py b/src/diagnosers/80-apps.py
index 3c336eae62..47715d25cf 100644
--- a/src/diagnosers/80-apps.py
+++ b/src/diagnosers/80-apps.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
from typing import List
diff --git a/src/diagnosers/__init__.py b/src/diagnosers/__init__.py
index 86d229abb0..3b3672e597 100644
--- a/src/diagnosers/__init__.py
+++ b/src/diagnosers/__init__.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
diff --git a/src/diagnosis.py b/src/diagnosis.py
index 9f542ea47c..2b4c124c02 100644
--- a/src/diagnosis.py
+++ b/src/diagnosis.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import re
import os
import time
diff --git a/src/dns.py b/src/dns.py
index ef79d55759..34f4f4f3a4 100644
--- a/src/dns.py
+++ b/src/dns.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import re
import time
diff --git a/src/domain.py b/src/domain.py
index 96dcb0851a..2646ef370f 100644
--- a/src/domain.py
+++ b/src/domain.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import time
from pathlib import Path
diff --git a/src/dyndns.py b/src/dyndns.py
index 7c538a4477..4c651e80a2 100644
--- a/src/dyndns.py
+++ b/src/dyndns.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import json
import glob
diff --git a/src/firewall.py b/src/firewall.py
index 4e7337a5dd..ff8f44f4f8 100644
--- a/src/firewall.py
+++ b/src/firewall.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import yaml
import miniupnpc
diff --git a/src/hook.py b/src/hook.py
index acba650beb..d1d5ceebc4 100644
--- a/src/hook.py
+++ b/src/hook.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import re
import sys
diff --git a/src/log.py b/src/log.py
index cd70c06c0c..b25e240502 100755
--- a/src/log.py
+++ b/src/log.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python3
+#
# Copyright (c) 2024 YunoHost Contributors
#
# This file is part of YunoHost (see https://yunohost.org)
@@ -15,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import copy
import os
import re
diff --git a/src/migrations/0027_migrate_to_bookworm.py b/src/migrations/0027_migrate_to_bookworm.py
index b26128e364..b0becaac36 100644
--- a/src/migrations/0027_migrate_to_bookworm.py
+++ b/src/migrations/0027_migrate_to_bookworm.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import glob
import os
import subprocess
diff --git a/src/migrations/0028_delete_legacy_xmpp_permission.py b/src/migrations/0028_delete_legacy_xmpp_permission.py
index de5d2b9832..db37a011a9 100644
--- a/src/migrations/0028_delete_legacy_xmpp_permission.py
+++ b/src/migrations/0028_delete_legacy_xmpp_permission.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
from logging import getLogger
from yunohost.tools import Migration
diff --git a/src/migrations/0029_postgresql_13_to_15.py b/src/migrations/0029_postgresql_13_to_15.py
index f74d33a761..8cafd87b08 100644
--- a/src/migrations/0029_postgresql_13_to_15.py
+++ b/src/migrations/0029_postgresql_13_to_15.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import subprocess
import time
import os
diff --git a/src/migrations/0030_rebuild_python_venv_in_bookworm.py b/src/migrations/0030_rebuild_python_venv_in_bookworm.py
index 4534d58834..8d1670e6b6 100644
--- a/src/migrations/0030_rebuild_python_venv_in_bookworm.py
+++ b/src/migrations/0030_rebuild_python_venv_in_bookworm.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import os
from logging import getLogger
diff --git a/src/migrations/0031_terms_of_services.py b/src/migrations/0031_terms_of_services.py
index b56fec0e6c..bf5c2b01ae 100644
--- a/src/migrations/0031_terms_of_services.py
+++ b/src/migrations/0031_terms_of_services.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
from moulinette import m18n
from yunohost.tools import Migration
diff --git a/src/migrations/__init__.py b/src/migrations/__init__.py
index e69de29bb2..3b3672e597 100644
--- a/src/migrations/__init__.py
+++ b/src/migrations/__init__.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
diff --git a/src/permission.py b/src/permission.py
index 8fb7d3499f..c58805c7c9 100644
--- a/src/permission.py
+++ b/src/permission.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import re
import copy
import grp
diff --git a/src/portal.py b/src/portal.py
index a52c223a04..45c60cb46b 100644
--- a/src/portal.py
+++ b/src/portal.py
@@ -1,23 +1,23 @@
-# -*- coding: utf-8 -*-
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
-""" License
-
- Copyright (C) 2021 YUNOHOST.ORG
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program; if not, see http://www.gnu.org/licenses
-
-"""
import logging
from pathlib import Path
from typing import Any, Union
diff --git a/src/regenconf.py b/src/regenconf.py
index 05a6edf815..8f2b28527d 100644
--- a/src/regenconf.py
+++ b/src/regenconf.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import yaml
import shutil
diff --git a/src/service.py b/src/service.py
index d53d011088..c9344b05b9 100644
--- a/src/service.py
+++ b/src/service.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import re
import os
import time
diff --git a/src/settings.py b/src/settings.py
index aee49c0132..424f228a0d 100644
--- a/src/settings.py
+++ b/src/settings.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import subprocess
from logging import getLogger
diff --git a/src/ssh.py b/src/ssh.py
index ae09b71177..5e54804463 100644
--- a/src/ssh.py
+++ b/src/ssh.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
diff --git a/src/tests/__init__.py b/src/tests/__init__.py
index e69de29bb2..3b3672e597 100644
--- a/src/tests/__init__.py
+++ b/src/tests/__init__.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
diff --git a/src/tests/conftest.py b/src/tests/conftest.py
index 21850fec33..a16b0482c1 100644
--- a/src/tests/conftest.py
+++ b/src/tests/conftest.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import os
import pytest
from unittest.mock import Mock
diff --git a/src/tests/test_app_catalog.py b/src/tests/test_app_catalog.py
index f436dd8774..77293fab14 100644
--- a/src/tests/test_app_catalog.py
+++ b/src/tests/test_app_catalog.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import os
import pytest
import requests
diff --git a/src/tests/test_app_config.py b/src/tests/test_app_config.py
index 24abdc5dc1..5a201477e5 100644
--- a/src/tests/test_app_config.py
+++ b/src/tests/test_app_config.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import glob
import os
import shutil
diff --git a/src/tests/test_app_resources.py b/src/tests/test_app_resources.py
index 38e712a29f..0276917940 100644
--- a/src/tests/test_app_resources.py
+++ b/src/tests/test_app_resources.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import os
import pytest
diff --git a/src/tests/test_apps.py b/src/tests/test_apps.py
index ede986b100..bc6c0ee2e1 100644
--- a/src/tests/test_apps.py
+++ b/src/tests/test_apps.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import glob
import os
import pytest
diff --git a/src/tests/test_appurl.py b/src/tests/test_appurl.py
index 8d1c43f15f..90840ad767 100644
--- a/src/tests/test_appurl.py
+++ b/src/tests/test_appurl.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import pytest
import os
diff --git a/src/tests/test_backuprestore.py b/src/tests/test_backuprestore.py
index b55e5b11b7..b316c3e99b 100644
--- a/src/tests/test_backuprestore.py
+++ b/src/tests/test_backuprestore.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import pytest
import os
import shutil
diff --git a/src/tests/test_changeurl.py b/src/tests/test_changeurl.py
index b8ca20355f..d1babbb032 100644
--- a/src/tests/test_changeurl.py
+++ b/src/tests/test_changeurl.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import pytest
import time
import requests
diff --git a/src/tests/test_dns.py b/src/tests/test_dns.py
index 744e3e7899..77c2040387 100644
--- a/src/tests/test_dns.py
+++ b/src/tests/test_dns.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import pytest
from moulinette.utils.filesystem import read_toml
diff --git a/src/tests/test_domains.py b/src/tests/test_domains.py
index 273b8689aa..f6bfdba352 100644
--- a/src/tests/test_domains.py
+++ b/src/tests/test_domains.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import pytest
import os
import random
diff --git a/src/tests/test_ldapauth.py b/src/tests/test_ldapauth.py
index 73cb09d274..a7c9173082 100644
--- a/src/tests/test_ldapauth.py
+++ b/src/tests/test_ldapauth.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import pytest
import os
diff --git a/src/tests/test_permission.py b/src/tests/test_permission.py
index 302173b1ca..ed80684135 100644
--- a/src/tests/test_permission.py
+++ b/src/tests/test_permission.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import socket
import requests
import pytest
diff --git a/src/tests/test_questions.py b/src/tests/test_questions.py
index af8bc4469f..ba63e30472 100644
--- a/src/tests/test_questions.py
+++ b/src/tests/test_questions.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import inspect
import sys
import pytest
diff --git a/src/tests/test_regenconf.py b/src/tests/test_regenconf.py
index 3966ef2911..a56364d8bd 100644
--- a/src/tests/test_regenconf.py
+++ b/src/tests/test_regenconf.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import os
from .conftest import message
diff --git a/src/tests/test_service.py b/src/tests/test_service.py
index 84573fd899..08f729a7b9 100644
--- a/src/tests/test_service.py
+++ b/src/tests/test_service.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import os
from .conftest import raiseYunohostError
diff --git a/src/tests/test_settings.py b/src/tests/test_settings.py
index 20f959a800..39d1f25aa4 100644
--- a/src/tests/test_settings.py
+++ b/src/tests/test_settings.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import os
import pytest
import yaml
diff --git a/src/tests/test_sso_and_portalapi.py b/src/tests/test_sso_and_portalapi.py
index 3defa7dc97..1a9b9e31a3 100644
--- a/src/tests/test_sso_and_portalapi.py
+++ b/src/tests/test_sso_and_portalapi.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import base64
import time
import requests
diff --git a/src/tests/test_user-group.py b/src/tests/test_user-group.py
index f347fc9bcc..f8156695a6 100644
--- a/src/tests/test_user-group.py
+++ b/src/tests/test_user-group.py
@@ -1,3 +1,23 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
import pytest
from .conftest import message, raiseYunohostError
diff --git a/src/tools.py b/src/tools.py
index 2efe2fc195..5a8d19d1b0 100644
--- a/src/tools.py
+++ b/src/tools.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import pwd
import re
import os
diff --git a/src/user.py b/src/user.py
index a16f5e04b7..921987eaa2 100644
--- a/src/user.py
+++ b/src/user.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import re
import pwd
diff --git a/src/utils/__init__.py b/src/utils/__init__.py
index 86d229abb0..3b3672e597 100644
--- a/src/utils/__init__.py
+++ b/src/utils/__init__.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
diff --git a/src/utils/configpanel.py b/src/utils/configpanel.py
index 37318813ea..4bdec1030f 100644
--- a/src/utils/configpanel.py
+++ b/src/utils/configpanel.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import glob
import os
import re
diff --git a/src/utils/dns.py b/src/utils/dns.py
index 8d4d55c6a1..20e458a9fb 100644
--- a/src/utils/dns.py
+++ b/src/utils/dns.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import dns.resolver
from typing import List
diff --git a/src/utils/error.py b/src/utils/error.py
index 3ed62d24ae..a5cd78f04e 100644
--- a/src/utils/error.py
+++ b/src/utils/error.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
from moulinette.core import MoulinetteError, MoulinetteAuthenticationError
from moulinette import m18n
diff --git a/src/utils/form.py b/src/utils/form.py
index b6a6cf9666..a22280a32f 100644
--- a/src/utils/form.py
+++ b/src/utils/form.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import ast
import datetime
import operator as op
diff --git a/src/utils/i18n.py b/src/utils/i18n.py
index 48c282737e..f7de406c59 100644
--- a/src/utils/i18n.py
+++ b/src/utils/i18n.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
from moulinette import m18n
diff --git a/src/utils/ldap.py b/src/utils/ldap.py
index 9be70de200..9812dea2e1 100644
--- a/src/utils/ldap.py
+++ b/src/utils/ldap.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import atexit
import logging
diff --git a/src/utils/legacy.py b/src/utils/legacy.py
index f9e6b86611..e1ed50f287 100644
--- a/src/utils/legacy.py
+++ b/src/utils/legacy.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import re
import glob
diff --git a/src/utils/network.py b/src/utils/network.py
index 00b465205e..f6b1e19351 100644
--- a/src/utils/network.py
+++ b/src/utils/network.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import re
import logging
diff --git a/src/utils/password.py b/src/utils/password.py
index 7e20dc85f3..27cf5a76df 100644
--- a/src/utils/password.py
+++ b/src/utils/password.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
diff --git a/src/utils/resources.py b/src/utils/resources.py
index b4707e5076..0f5219fe06 100644
--- a/src/utils/resources.py
+++ b/src/utils/resources.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import os
import copy
import shutil
diff --git a/src/utils/system.py b/src/utils/system.py
index e46c4c64cb..ca38c96cdb 100644
--- a/src/utils/system.py
+++ b/src/utils/system.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import re
import os
import logging
diff --git a/src/utils/yunopaste.py b/src/utils/yunopaste.py
index 8032ff6294..5e40643158 100644
--- a/src/utils/yunopaste.py
+++ b/src/utils/yunopaste.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python3
#
# Copyright (c) 2024 YunoHost Contributors
#
@@ -16,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
#
+
import requests
import json
import logging
diff --git a/src/vendor/__init__.py b/src/vendor/__init__.py
index e69de29bb2..e5a0d9b483 100644
--- a/src/vendor/__init__.py
+++ b/src/vendor/__init__.py
@@ -0,0 +1 @@
+#!/usr/bin/env python3
diff --git a/src/vendor/acme_tiny/__init__.py b/src/vendor/acme_tiny/__init__.py
index e69de29bb2..3b3672e597 100644
--- a/src/vendor/acme_tiny/__init__.py
+++ b/src/vendor/acme_tiny/__init__.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+#
+# Copyright (c) 2024 YunoHost Contributors
+#
+# This file is part of YunoHost (see https://yunohost.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#