python / python/mypy

Recognize platform.system() as well as sys.platform

Ouverte
#8,166 12 commentaires 3 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

feature good-second-issue priority-1-normal topic-runtime-semantics
Langage dominant
Python
Étoiles
20.6k
Forks
3.3k
Métriques de merge des PR
Métriques de PR en attente

Description

Note: if you are reporting a wrong signature of a function or a class in
the standard library, then the typeshed tracker is better suited
for this report: https://github.com/python/typeshed/issues

Please provide more information to help us understand the issue:

  • Are you reporting a bug, or opening a feature request? feature request
  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.
    if platform.system() != "Windows":  # sys.platform != "win32":
        try:
            # os.confstr("CS_GNU_LIBC_VERSION") returns a string like "glibc 2.17".
            version_string = os.confstr("CS_GNU_LIBC_VERSION")
            assert version_string is not None
            _, version = version_string.split()
        except (AssertionError, OSError, ValueError):
            # os.confstr() or CS_GNU_LIBC_VERSION not available (or a bad value)...
            return None
        return version
    return None
  • What is the actual behavior/output? "error: Module has no attribute "confstr""
  • What is the behavior/output you expect? No error when run under Windows
  • What are the versions of mypy and Python you are using? mypy 0.750, Python 3.7.4

Basically it would be nice to get to use platform.system() instead of having to use sys.platform to make mypy happy with code that is conditional on the platform.

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par le repro Python fourni et comparez la manière dont mypy traite platform.system() par rapport à sys.platform dans du code conditionnel. Identifiez le point d’entrée de l’analyse spécifique à la plateforme et vérifiez la modification en contrôlant que os.confstr n’est pas signalé comme manquant dans la branche Windows ; le payload ne nomme aucun fichier source ni aucun test.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
devtools
Type d'issue
Fonctionnalité
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
38/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.