From 19b3258ea07f5088664f3726b0ec7fd28a940ac6 Mon Sep 17 00:00:00 2001
From: Fabian Affolter <mail@fabian-affolter.ch>
Date: Fri, 3 Dec 2021 12:35:54 +0100
Subject: [PATCH] python3Packages.pydelijn: support for async_timeout >4

---
 .../python-modules/devolo-plc-api/default.nix     |  4 ++--
 .../python-modules/pydelijn/default.nix           | 15 ++++++++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/pkgs/development/python-modules/devolo-plc-api/default.nix b/pkgs/development/python-modules/devolo-plc-api/default.nix
index 7a513233b19d..5abe989e98d5 100644
--- a/pkgs/development/python-modules/devolo-plc-api/default.nix
+++ b/pkgs/development/python-modules/devolo-plc-api/default.nix
@@ -14,7 +14,7 @@
 
 buildPythonPackage rec {
   pname = "devolo-plc-api";
-  version = "0.6.4";
+  version = "0.7.0";
   format = "setuptools";
 
   disabled = pythonOlder "3.8";
@@ -23,7 +23,7 @@ buildPythonPackage rec {
     owner = "2Fake";
     repo = "devolo_plc_api";
     rev = "v${version}";
-    sha256 = "sha256-hlIHNVJG/2hU5psGXhi05SCupORfgIjB+YT/ZlJEqFM=";
+    sha256 = "sha256-qzjH52bKQ/oSFd580V92uE2/Z2g+2nLh/JXOXYqVfSY=";
   };
 
   SETUPTOOLS_SCM_PRETEND_VERSION = version;
diff --git a/pkgs/development/python-modules/pydelijn/default.nix b/pkgs/development/python-modules/pydelijn/default.nix
index 08a3bf823611..f8a5d2ed4ae9 100644
--- a/pkgs/development/python-modules/pydelijn/default.nix
+++ b/pkgs/development/python-modules/pydelijn/default.nix
@@ -10,6 +10,8 @@
 buildPythonPackage rec {
   pname = "pydelijn";
   version = "0.6.1";
+  format = "setuptools";
+
   disabled = pythonOlder "3.6";
 
   src = fetchPypi {
@@ -23,10 +25,21 @@ buildPythonPackage rec {
     pytz
   ];
 
+  postPatch = ''
+    # Remove with next release
+    substituteInPlace setup.py \
+      --replace "async_timeout>=3.0.1,<4.0" "async_timeout>=3.0.1"
+    # https://github.com/bollewolle/pydelijn/pull/11
+    substituteInPlace pydelijn/common.py \
+      --replace ", loop=self.loop" ""
+  '';
+
   # Project has no tests
   doCheck = false;
 
-  pythonImportsCheck = [ "pydelijn" ];
+  pythonImportsCheck = [
+    "pydelijn"
+  ];
 
   meta = with lib; {
     description = "Python package to retrieve realtime data of passages at stops of De Lijn";