When Is A Bug Not A Bug in Python?

Photo by Alan Emery on Unsplash

While writing a chess program in Python as a learning exercise, I had two separate functions for converting a position from an algebraic notation string, 'a1', to a tuple, (97, 1), and vice versa. I later merged the two functions into a static method for the Board class. The code works. I should have left it at that and move on.

I found any interesting situation when refactoring the code to work with @functools.singledispatch and @staticmethod in a class. The code worked but I was using the wrong single dispatch decorator. When is a bug not a bug?

Read my essay and follow me on Medium. Your support is greatly appreciated.

Silicon Valley Auto Show Postponed Until 2023

The Silicon Valley Auto Show got cancelled due to the coronavirus in 2021. The 2022 show was scheduled for January at the San Jose Convention Center, and later postponed to July at the Santa Clara Convention Center. Not anymore. This year’s show got postponed to February 2023 at the Santa Clara Convention center. Not because of the coronavirus, but supply chain issues.

Read more “Silicon Valley Auto Show Postponed Until 2023”

The Incompatible Type Assignment Error in Mypy

Photo by Antoine Dautry on Unsplash

I’m writing a chess program in Python as a learning exercising. Not surprisingly, mypy, the static type checker, complained about my code with yet another incomprehensible error message. Here’s a quick-and-dirty fix for the incompatible type assignment error.

Read my essay and follow me on Medium. Your support is greatly appreciated.

Upgrading My TrueNAS File Server by ACCIDENT

Last week I noticed a critical error message notification on my TrueNAS file server. Device ada0 had 300,000 unreadable sectors pending. My seven-year-old Western Digital 1TB Red NAS hard drive was finally on the way out. I ordered a Western Digital 2TB Red Plus NAS hard drive from Amazon. A couple of hours later, I discovered that ada0 wasn’t a hard drive but an SSD. The new hard drive had already shipped from Amazon. I ended up upgrading my file server by accident.

Read more “Upgrading My TrueNAS File Server by ACCIDENT”

My 25-Year-Old Quake 2 Mouse Pad

A twit on Twitter wrote that playing a “first person shooter game past 30 ain’t a pleasant experience.” That was in reference to FortNite, which is a third-person shooter and not a first-person shooter. I responded that I’m 52-years-old, still using my Quake II mouse pad from 1997 to play video games and to get off my virtual lawn. That was one of my most popular tweets ever. Let’s talk about my 25-year-old Quake II mouse pad on my desk.

Read more “My 25-Year-Old Quake 2 Mouse Pad”

Fixing A String Issue with Enum.name in MyPy

Photo by Mel Poole on Unsplash

While cleaning up code in my chess program that I’m writing in Python as a learning exercise, I came across yet another problem with the mypy static type checker. This time with the Enum.name attribute.

color = Color(self._color).name.capitalize()

The statement worked but mypy reported an error message.

error: Item “None” of “Optional[str]” has no attribute “capitalize”

I came up with a solution for that problem.

Read my essay and follow me on Medium. Your support is greatly appreciated.

Fixing “None” Not Callable Error in Mypy

Photo by David Travis on Unsplash

The mypy static type checker always complain about using a dictionary to call functions. Especially this code segment from my chess program that I’m writing in Python as a learning exercise.

status = {Bishop: self.validate_move_bishop,
King: self.validate_move_king,
Knight: self.validate_move_knight,
Pawn: self.validate_move_pawn,
Queen: self.validate_move_queen,
Rook: self.validate_move_rook,
}.get(type(self._board[start]))(start, end)

This message, error: “None” not callable, always leave me cross-eyed at times. I came up with a solution for that problem.

Read my essay and follow me on Medium. Your support is greatly appreciated.