Hi all,[...]
I am fairly new to python (ie < 2 years). I have a question about
pylint. I am running on windows 10/11, python 3.10.11.
if p.returncode >= 8:
raise Exception(f'Invalid result: {p.returncode}')
It actually runs fine. But pylint is not having it. I get:
win_get_put_tb_filters.py:61:12: W0719: Raising too general exception: Exception (broad-exception-raised)
outer quotation marks) prints some prominent exception types. After...
manually removing those that do not seem to apply, I am left with: >"AssertionError",
"ChildProcessError",
Trying to read the python Exception docs is mind bending. Any help
would be appreciated.
ram@zedat.fu-berlin.de (Stefan Ram) writes:
outer quotation marks) prints some prominent exception types. After...
manually removing those that do not seem to apply, I am left with:
"AssertionError",
"ChildProcessError",
"Manually removing" above was meant to be a fast first pass,
where I only excluded exception types that were obviously
inappropriate. It is now to be followed by a search for the
appropriate exception types among those exception types left.
On 10/25/2023 11:06 AM, Stefan Ram wrote:
ram@zedat.fu-berlin.de (Stefan Ram) writes:@Rene & @Stefan,
outer quotation marks) prints some prominent exception types. After...
manually removing those that do not seem to apply, I am left with:
"AssertionError",
"ChildProcessError",
"Manually removing" above was meant to be a fast first pass,
where I only excluded exception types that were obviously
inappropriate. It is now to be followed by a search for the
appropriate exception types among those exception types left.
I really appreciate the guidance provided. By replacing Exception
with RuntimeError, pylint seems happy! More specificity, I guess. I
know that I could have ignored the pylint exceptions, but I want to
use this as a learning experience. I looks like I have a lot of
reading to do on exception handling. IMO all of the try/except code
looks quite clumsy to me. It may be excellent for some tasks but to
me, it looks quite inelegant. Like I said, I have a lot to learn.
From what you've described of your problem, it seems like a small-ishutility program you're writing for your own use. You don't need any `try`...`except` blocks in such code. You just let the exception stop
On 10/25/2023 11:06 AM, Stefan Ram wrote:
ram@zedat.fu-berlin.de (Stefan Ram) writes:@Rene & @Stefan,
outer quotation marks) prints some prominent exception types. After...
manually removing those that do not seem to apply, I am left with:
"AssertionError",
"ChildProcessError",
"Manually removing" above was meant to be a fast first pass,
where I only excluded exception types that were obviously
inappropriate. It is now to be followed by a search for the
appropriate exception types among those exception types left.
I really appreciate the guidance provided. By replacing Exception with RuntimeError, pylint seems happy! More specificity, I guess. I know
that I could have ignored the pylint exceptions, but I want to use this
as a learning experience. I looks like I have a lot of reading to do on exception handling. IMO all of the try/except code looks quite clumsy to me. It may be excellent for some tasks but to me, it looks quite inelegant. Like I said, I have a lot to learn.
Thank you both for your guidance.
Richard
On 10/25/2023 11:06 AM, Stefan Ram wrote:...
ram@zedat.fu-berlin.de (Stefan Ram) writes:
outer quotation marks) prints some prominent exception types. After
..."Manually removing" above was meant to be a fast first pass,@Rene & @Stefan,
where I only excluded exception types that were obviously
inappropriate. It is now to be followed by a search for the
appropriate exception types among those exception types left.
I really appreciate the guidance provided. By replacing Exception with
rsutton <rsutton43@comcast.net> wrote:^^^^^^^^^^^^^^^^
Hi all,[...]
I am fairly new to python (ie < 2 years). I have a question about
pylint. I am running on windows 10/11, python 3.10.11.
if p.returncode >= 8:
raise Exception(f'Invalid result: {p.returncode}')
It actually runs fine. But pylint is not having it. I get:
win_get_put_tb_filters.py:61:12: W0719: Raising too general exception:
Exception (broad-exception-raised)
pylint is just a linter, ignore it if the code works and you like it the
way it is.
pylint complains because you use Exception. Use e.g. RuntimeException to silence it.
Rene Kita <mail@rkta.de> wrote:
rsutton <rsutton43@comcast.net> wrote:^^^^^^^^^^^^^^^^
Hi all,[...]
I am fairly new to python (ie < 2 years). I have a question about
pylint. I am running on windows 10/11, python 3.10.11.
if p.returncode >= 8:
raise Exception(f'Invalid result: {p.returncode}')
It actually runs fine. But pylint is not having it. I get:
win_get_put_tb_filters.py:61:12: W0719: Raising too general exception:
Exception (broad-exception-raised)
pylint is just a linter, ignore it if the code works and you like it the
way it is.
pylint complains because you use Exception. Use e.g. RuntimeException to
silence it.
Ingrid says it's a RuntimeError, not RuntimeException.
Of course, you can put that into the message you pass to the class
instance you raise, but the type of exception is informational too.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 60:07:37 |
Calls: | 6,712 |
Files: | 12,243 |
Messages: | 5,355,756 |