Skip to content

Conversation

@bblommers
Copy link
Contributor

Description

Refactors the src/autobahn folder to conform to ruff's UP rules.

Most changes were done automatically using ruff check --fix --unsafe-fixes --select UP src/autobahn/, with some manual intervention to adjust the remaining ones.


Related Issue(s)

Closes or relates to #1841


Checklist

  • I have referenced relevant issue numbers above
  • I have performed a self-review of my code and it follows
    the style guidelines of this project
  • I have added new or used existing tests that prove my fix
    is effective or that my feature works
  • I have added necessary documentation (if appropriate) and
    updated the changelog
  • I have added an AI assistance disclosure file (required!)
    in this PR

@bblommers bblommers marked this pull request as draft January 9, 2026 20:12
from typing import Any
from collections.abc import Callable

# FIXME: see ISecurityModule.__iter__
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There already was a FIXME in ISecurityModule.__iter__, so it seemed unnecessary to have it here as well

@bblommers bblommers force-pushed the chore-apply-ruff-up branch from 7588cf9 to cee77a0 Compare January 9, 2026 20:30
@bblommers bblommers marked this pull request as ready for review January 9, 2026 21:38
@oberstet oberstet merged commit 1c7d45c into crossbario:master Jan 10, 2026
33 checks passed
@oberstet
Copy link
Contributor

as a "note to self", cleaning up my mind, Claude to the rescue (bonus: I learned a new english word, "vestigial";)

before I merge PR #1843, just one more question rgd "3. Class inheritance — class Foo(object): → class Foo:" => can you explain please? why was that needed in the past anyways? was it related to twisted? I simply forgot "why" and just stuck to it (always derive from object for a final base class), and I want to "clean up my mind properly" so I'd like to understand the whole train of thoughts ;)

● Great question! This is Python 2 vs Python 3 history.

Python 2: Two Types of Classes

In Python 2, there were two fundamentally different class types:

  # Old-style class (classic class) - Python 2
  class Foo:
      pass

  # New-style class - Python 2.2+
  class Bar(object):
      pass

Why New-Style Classes Mattered

Feature Old-style New-style
Method Resolution Order (MRO) Depth-first, left-to-right C3 linearization (correct for diamond inheritance)
super() Broken/unavailable Works correctly
Descriptors (@Property, get, set) No Yes
slots No Yes
getattribute No Yes
type(instance) Returns <type 'instance'> Returns actual class

The Diamond Problem

  class A: pass        # old-style
  class B(A): pass
  class C(A): pass
  class D(B, C): pass  # MRO: D → B → A → C → A (A visited twice, wrong!)

  class A(object): pass  # new-style
  class B(A): pass
  class C(A): pass
  class D(B, C): pass    # MRO: D → B → C → A (correct C3 linearization)

Twisted Connection

Yes, Twisted specifically required new-style classes because:

  1. zope.interface (used by Twisted for implements()) required new-style classes
  2. Twisted's Deferred and protocol classes used descriptors
  3. Proper super() was needed for cooperative multiple inheritance

So for any Twisted-based codebase (like Autobahn), class Foo(object): was mandatory for Python 2 compatibility.

Python 3: All Classes Are New-Style

In Python 3, the distinction was removed. All classes are new-style by default:

  # Python 3 - these are 100% identical:
  class Foo:
      pass

  class Foo(object):
      pass

The (object) is now purely vestigial noise. The ruff rule UP004 removes it.

TL;DR

  • Python 2: (object) was required for correct MRO, super(), descriptors, and Twisted/zope.interface compatibility
  • Python 3: (object) does nothing — safe to remove

@bblommers bblommers deleted the chore-apply-ruff-up branch January 10, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants