Python Forum
Static type checking with PyPy
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Static type checking with PyPy
#1
I am using type hints as an experiment to see the pros and cons. I am also using PyPy a an experiment with static type checking.

Here's an inconvenient situation.

Say variable x can be None | list[int].

And say that I know based on an earlier conditional that x is not None.

But if I try to access x[1] I get a type error because the static type checker thinkgs it might be None.

What's the pythonic way to handle this?

Thanks!
Reply


Messages In This Thread
Static type checking with PyPy - by pitosalas - Dec-14-2023, 08:39 PM
RE: Static type checking with PyPy - by deanhystad - Dec-14-2023, 09:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem usage of static method akbarza 5 595 Feb-03-2024, 07:43 AM
Last Post: paul18fr
  Class member become static Quasar999 1 724 Sep-16-2023, 12:52 PM
Last Post: deanhystad
Photo Output Static image on HDMI2 random816382 0 1,424 Oct-18-2021, 11:21 AM
Last Post: random816382
  Type hinting - return type based on parameter micseydel 2 2,532 Jan-14-2020, 01:20 AM
Last Post: micseydel
  Are there optimizer for static code? AlekseyPython 5 2,620 Nov-03-2019, 07:52 AM
Last Post: AlekseyPython
  Using static methods for library? giu88 4 2,959 Sep-12-2018, 07:52 AM
Last Post: giu88
  Notebook is rendered as static html by github miner_tom 2 3,157 Aug-23-2018, 09:00 PM
Last Post: perfringo
  need to alter static picture to video file mika 1 2,771 Feb-23-2018, 02:11 PM
Last Post: ka06059
  Updating & Accessing a "Static" List Bass 4 4,471 May-23-2017, 07:12 PM
Last Post: Bass

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020