<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Konstantin Sofeikov</title>
    <description>The latest articles on DEV Community by Konstantin Sofeikov (@sofeikov).</description>
    <link>https://dev.to/sofeikov</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4243173%2Ff25d3e98-f34d-47e0-85fa-ba51a52b37b8.png</url>
      <title>DEV Community: Konstantin Sofeikov</title>
      <link>https://dev.to/sofeikov</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sofeikov"/>
    <language>en</language>
    <item>
      <title>Static shape checking for NumPy: one mypy plugin, precise shapes before anything runs</title>
      <dc:creator>Konstantin Sofeikov</dc:creator>
      <pubDate>Fri, 13 Nov 2026 15:04:05 +0000</pubDate>
      <link>https://dev.to/sofeikov/static-shape-checking-for-numpy-one-mypy-plugin-precise-shapes-before-anything-runs-1dk3</link>
      <guid>https://dev.to/sofeikov/static-shape-checking-for-numpy-one-mypy-plugin-precise-shapes-before-anything-runs-1dk3</guid>
      <description>&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sofeikov" rel="noopener noreferrer"&gt;
        sofeikov
      &lt;/a&gt; / &lt;a href="https://github.com/sofeikov/numty" rel="noopener noreferrer"&gt;
        numty
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Static shape checking for NumPy: one mypy plugin, precise shapes before anything runs
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;numty&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;
  &lt;b&gt;Static shape checking for NumPy.&lt;/b&gt;&lt;br&gt;
  Wrong-shaped arrays become mypy errors, before anything runs
&lt;/p&gt;

&lt;p&gt;
  &lt;a href="https://sofeikov.github.io/numty/" rel="nofollow noopener noreferrer"&gt;&lt;b&gt;Documentation&lt;/b&gt;&lt;/a&gt; ·
  &lt;a href="https://sofeikov.github.io/numty/get-started/" rel="nofollow noopener noreferrer"&gt;Get started&lt;/a&gt; ·
  &lt;a href="https://sofeikov.github.io/numty/examples/bug-gallery/" rel="nofollow noopener noreferrer"&gt;Bug gallery&lt;/a&gt; ·
  &lt;a href="https://sofeikov.github.io/numty/internals/limitations/" rel="nofollow noopener noreferrer"&gt;Limitations&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
  &lt;a href="https://github.com/sofeikov/numty/actions/workflows/ci.yml" rel="noopener noreferrer"&gt;&lt;img alt="CI" src="https://github.com/sofeikov/numty/actions/workflows/ci.yml/badge.svg"&gt;&lt;/a&gt;
  &lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/3392b7bd79aa135560ec6912f4c81741638c1617ed40b40230e64476ae5d1273/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e31332532422d626c7565"&gt;&lt;img alt="Python 3.13+" src="https://camo.githubusercontent.com/3392b7bd79aa135560ec6912f4c81741638c1617ed40b40230e64476ae5d1273/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e31332532422d626c7565"&gt;&lt;/a&gt;
  &lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/5f0424a2ca09110d1acacbbaa3303b069809942462f367c8fa79b8d9692f47db/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6e756d70792d322e352532422d626c7565"&gt;&lt;img alt="NumPy 2.5+" src="https://camo.githubusercontent.com/5f0424a2ca09110d1acacbbaa3303b069809942462f367c8fa79b8d9692f47db/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6e756d70792d322e352532422d626c7565"&gt;&lt;/a&gt;
  &lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/983d4359659e5a2c96c77d98d5ef94b6b62d718a4a78082edf59726cc3a1903f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e"&gt;&lt;img alt="MIT license" src="https://camo.githubusercontent.com/983d4359659e5a2c96c77d98d5ef94b6b62d718a4a78082edf59726cc3a1903f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e"&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
  &lt;a rel="noopener noreferrer" href="https://github.com/sofeikov/numty/docs/assets/hero.svg"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fsofeikov%2Fnumty%2FHEAD%2Fdocs%2Fassets%2Fhero.svg" width="920" alt="Twelve lines of plain NumPy in an editor. numty infers each shape and mypy reports a transposed weight matrix and a missing keepdims before the code runs."&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;That file imports nothing from numty and annotates nothing. numty worked
out that &lt;code&gt;reshape(64, -1)&lt;/code&gt; of &lt;code&gt;(64, 28, 28)&lt;/code&gt; is &lt;code&gt;(64, 784)&lt;/code&gt;, carried it
into the &lt;code&gt;@&lt;/code&gt;, and saw that &lt;code&gt;sum(axis=1)&lt;/code&gt; drops an axis the division needs.&lt;/p&gt;
&lt;p&gt;The second bug is the dangerous kind. With 10 samples instead of 64, NumPy
would broadcast &lt;code&gt;(10, 10) / (10,)&lt;/code&gt; without complaint and return
probabilities normalised along the wrong axis.&lt;/p&gt;

The same example as text
&lt;div class="highlight highlight-source-python notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;import&lt;/span&gt; &lt;span class="pl-s1"&gt;numpy&lt;/span&gt; &lt;span class="pl-k"&gt;as&lt;/span&gt; &lt;span class="pl-s1"&gt;np&lt;/span&gt;
&lt;span class="pl-s1"&gt;images&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s1"&gt;np&lt;/span&gt;.&lt;span class="pl-c1"&gt;zeros&lt;/span&gt;((&lt;span class="pl-c1"&gt;64&lt;/span&gt;, &lt;span class="pl-c1"&gt;28&lt;/span&gt;, &lt;span class="pl-c1"&gt;28&lt;/span&gt;))
&lt;span class="pl-s1"&gt;weights&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s1"&gt;np&lt;/span&gt;.&lt;span class="pl-c1"&gt;zeros&lt;/span&gt;((&lt;span class="pl-c1"&gt;10&lt;/span&gt;, &lt;span class="pl-c1"&gt;784&lt;/span&gt;))  &lt;span class="pl-c"&gt;# transposed: should be (784, 10)&lt;/span&gt;
&lt;span class="pl-s1"&gt;bias&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s1"&gt;np&lt;/span&gt;.&lt;span class="pl-c1"&gt;zeros&lt;/span&gt;(&lt;span class="pl-c1"&gt;10&lt;/span&gt;)

&lt;span class="pl-s1"&gt;flat&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-s1"&gt;images&lt;/span&gt;.&lt;span class="pl-c1"&gt;reshape&lt;/span&gt;(&lt;span class="pl-c1"&gt;64&lt;/span&gt;, &lt;span class="pl-c1"&gt;-&lt;/span&gt;&lt;span class="pl-c1"&gt;1&lt;/span&gt;)
&lt;span class="pl-s1"&gt;logits&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt;&lt;/pre&gt;…
&lt;/div&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sofeikov/numty" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>github</category>
      <category>opensource</category>
      <category>python</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
