Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfm4T-0003bA-0H for psycopg@arkaria.postgresql.org; Thu, 19 Nov 2020 15:42:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kfm4R-0006t6-02 for psycopg@arkaria.postgresql.org; Thu, 19 Nov 2020 15:42:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfm4Q-0006sc-Om for psycopg@lists.postgresql.org; Thu, 19 Nov 2020 15:42:02 +0000 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kfm4O-0005Hs-Dp for psycopg@postgresql.org; Thu, 19 Nov 2020 15:42:01 +0000 Received: by mail-ot1-x32e.google.com with SMTP id y22so5654857oti.10 for ; Thu, 19 Nov 2020 07:42:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=hs0Tv/y74K995dmsHy/IkGQH8IdWrSvCnxtIqj0iksg=; b=r+cBCKZ2MqXnTHkCSzZAGqww9R7hVTL9jD2FWN0xwcwMit6NODn+ENajDse+1FLwBm WIMFsuuVDVevnzqBQxkAqUGkUw318VNWyGLFWLmUNHsE+IBine0fqSt+vJCjY5Rb0vGf nAwIR76EQ9HXaxcBcFZHnECud67CUsvJqNPrba4FW5x6ChqiJKSlzJQeywVUUl/UrnKj ThyDdXiCIgQuWzQ3z73IVWukTI97cN/Nb9EQVQLRajEuFUmZgZw/UbseJ+WEDTzKfsJb KvSl5srAy/uklwuoh/Gr6qJtTN7hZKXMvxv+SgRGwX6Fsx70dAsKpDOJ3lvoERneUbuR HoEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=hs0Tv/y74K995dmsHy/IkGQH8IdWrSvCnxtIqj0iksg=; b=ADprg1bjgc9JI9syMGLfZ+s0WLl3jHwFm78YrG+1m7Np6NheLtE6nm07ODxF4Isj+X Fa4JoI0i7ZK4c2t73I8cZa7ypir5zVWmDE02CPMxFiJCaCGc8esN901eEwRQCgwK+dsz mBvbN7zEXubiSDc3nEF8rm2HCl7on68AISqn6EEV+zvbvS/oxccSlvV/b2ibNdrckhOD zheJmb8MNnphpy0YLb7ZfyGZqYSR3JtgVUP7jwBAnY8uenYPAQlID+EkwX3MeZ25SQ4S qYpBayzct16Oo6dTj61IuGqNqOWJ06GAolE//ELFl9qjQybByl6k6B6IW2IGmsDITA4w ookg== X-Gm-Message-State: AOAM531FG0aDJWA/abq/DH7MR2CvsNszBYWdpL7P7HpKHryhVmFS3qhX W8mUkKkqpNpBHbBLEfwmA3YXC+w28TmRcKyZLBrCOwFNn4jvPQ== X-Google-Smtp-Source: ABdhPJwOH/rEhki/9dwRBQvEpyx/RclAUjdJJjGyP1XrGFIXQS+e+9rxbwuJRCMoldE7B5QIDRpept2uLl2zJ5iwopY= X-Received: by 2002:a05:6830:1aec:: with SMTP id c12mr9967243otd.227.1605800519345; Thu, 19 Nov 2020 07:41:59 -0800 (PST) MIME-Version: 1.0 From: Patrick Starrenburg Date: Thu, 19 Nov 2020 16:41:48 +0100 Message-ID: Subject: 'Psycopg2.errors' not referenced in packaged To: psycopg@postgresql.org Content-Type: multipart/alternative; boundary="00000000000089281a05b4779142" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --00000000000089281a05b4779142 Content-Type: text/plain; charset="UTF-8" Hi I am using psycopg2 in a Django app. In my code I am checking for various exceptions, one of which is foreign key violations. I see in the psycopg2 docs https://www.psycopg.org/docs/errors.html that ForeignKeyViolation is under the base IntegrityError exception. I would like to be able to specifically catch, and respond to the ForeignKeyViolation error. I am coding using the recommendation in the docs (below). It is working (a forced FK violation is specifically caught) my question is though that in my IDE (PyCharm) it reports that it cannot find the reference 'errors' and I cannot use dotted links to drill down to the errors.ForeignKeyViolation function. I can type psycopg2.IntegrityError and reference to it is found (and I see that it is listed in the __init.py__ file). When I Google this some say it is a PyCharm bug, some say that PyCharm is following the Python package convention. Can anyone advise. Thanks in advance. Patrick try: cursor_wsr.close() conn.commit() conn.close() except psycopg2.errors.ForeignKeyViolation as err: Cannot find reference 'errors' in '__init__.py | __init__.py' Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items. --00000000000089281a05b4779142 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

I am using psycopg2 in a = Django app. In my code I am checking for various exceptions, one of which i= s foreign key violations.

I see in the psycopg2 do= cs https://www.psycopg= .org/docs/errors.html that ForeignKeyViolation
=
is under the base IntegrityError exception. I = would like to be able to specifically catch, and respond to the ForeignKeyV= iolation error. I am coding using the recommendation in the docs (below).

It is working (a forced FK violation is specificall= y caught) my question is though that in my IDE (PyCharm) it reports that it= cannot find the reference 'errors' and I cannot use dotted links t= o drill down to the errors.ForeignKeyViolation function.

I can type psycopg2.IntegrityError and reference to it is found (and= I see that it is listed in the __init.py__ file).

When I Google this some say it is a PyCharm bug, some say that PyCharm is = following the Python package convention.

Can a= nyone advise.

Thanks in advance.
Patrick

t=
ry:
cursor_wsr.close()
conn.commit()
conn.close= ()
except psy= copg2.errors.Foreig= nKeyViolation as err:

Cannot find reference 'errors' in '__init__.py | _= _init__.py'
Inspection info: This inspection detects names that sho= uld resolve but don't. Due to dynamic dispatch and duck typing, this is= possible in a limited but useful number of cases. Top-level and class-leve= l items are supported better than instance items.
--00000000000089281a05b4779142--