Skip to content

Typecheckers see all Confuse config values as type 'object' in v2.2.0 only #191

@ajslater

Description

@ajslater

As of Confuse 2.2.0 both basedpyright and astral's ty typechecker see all Confuse config AttrDict values as the 'object' type, creating an enormous amount of typechecking warnings.

In this real example from my comicbox repo self.config.verbose is declared in the MappingTemplate as an Integer().
The class Printer() takes an int argument. Which typechecks fine in Confuse v2.1.0.

self._printer: Printer = Printer(self.config.verbose)   

However in Confuse 2.2.0 my typechecker shows:

ty: Argument to bound method `__init__` is incorrect: Expected `int`, found `object`                               
invalid-argument-type: Argument to bound method `__init__` is incorrect: Expected `int`, found `object`

Naturally as I use Confuse config values everywhere I see many of these type checking warnings.

The good news is this isn't a functional bug and everything still works, but it makes typing of the config object useless.

Workaround

Reverting to Confuse 2.1.0 fixes this.

Reproduction

My nudebomb repo is a reasonably small codebase that shows this.

https://github.com/ajslater/nudebomb/tree/v0.4.7

  1. Checkout tag v0.4.7 onto a machine with python, uv and make.
  2. make update will install the latest packages including Confuse 2.2.0
  3. make typecheck will show basedpyright warnings.
  4. make ty will show warnings from ty.

Identical issue also seen in my picopt and comicbox repos.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions