[Feature Request]: get type checking working during argument parsing

Aperta
#10,575 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@wgreenberg ci sta già lavorando.

Dal 12/2/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

What problem does this feature solve or what does it enhance?

in the past few months, we've had three different bugs caused by the absence of type checking on the argparse.Namespace object during argument parsing. i think we should fix this so our tools can catch this kind of thing for us

Proposed Solution

i think the best way to do this is to implement something like what i did at https://gist.github.com/bmw/459b81b21eeb3ab13fb1a974dfc994e5. this is only meant to be a proof of concept so pretty much all design decisions here and especially things like naming and which files to put this in should be revisited, but i've confirmed that an approach like this would allow mypy to catch these kind of bugs

beyond this basic problem and solution, i think there's still a number of design decisions to be made here, especially if we're interested in making this a larger project. there was some discussion about this in a private mattermost channel in the thread starting here which may be helpful to refer back to

to pull some points from that discussion that i personally think are important, we for starters need a way to get all the expected types documented somewhere so mypy can use them for static analysis. we may also want to set up logic so our code errors if we add a new command line argument and forget to specify its type in this new system. an important thing to keep in mind about errors like this though is we should ensure things still work for 3rd party plugins which certbot currently has hundreds of

going beyond the problems during argument parsing, our NamespaceConfig object also has limited type checking and i doubt my gist would help with that as __getattr__ returns Any. perhaps there's more refactoring that could/should be done here around this and/or the CLI_DEFAULTS object

in my mind, this issue is primarily a design issue to figure out the exact path forward here. if whoever takes this wants to then create subissues that can be divvied up amongst the team, i personally think that is very reasonable, but i wanted to create this initial issue here to help keep us working and thinking about this problem. i personally think it's important and likely to help us in the future

Alternatives Considered

No response

Lingua principale
Python
Stelle
33.4k
Fork
3.5k
Merge medio
4g 2h
PR unite (30g)
11

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di certbot/certbot

Tutte le issue di certbot/certbot

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.