note: A user-defined top-level module with name "XXX" is not supported
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Bug Report
I get the following unexpected error.
mypy graph.py
Then, I got the following error.
mypy: "abc.py" shadows library module "abc"
note: A user-defined top-level module with name "abc" is not supported
In the same folder there is a file named abc.py. However I did not check the 'abc.py'. Why I got this kind of error ??
To Reproduce
# graph.py
from collections import defaultdict
from typing import Generic, NewType, TypeVar, Union, List
Restaurant = NewType('Restaurant', str)
Recipe = NewType('Recipe', str)
Node = TypeVar("Node")
Edge = TypeVar("Edge")
class Graph(Generic[Node, Edge]):
def __init__(self):
self.edges: dict[Node, List[Edge]] = defaultdict(list)
def add_relation(self, node: Node, to: Edge):
self.edges[node].append(to)
def get_relations(self, node: Node) -> List[Edge]:
return self.edges[node]
restaurants: Graph[Restaurant, Restaurant] = Graph()
recipes: Graph[Recipe, Recipe] = Graph()
restaurant_dishes: Graph[Restaurant, Recipe] = Graph()
recipes.add_relation(Recipe('Pasta Bolognese'),
Recipe('Pasta with Sausage and Basil'))
restaurant_dishes.add_relation(Restaurant('Viafores'),
Recipe('Pasta Bolognese'))
# abc.py
import collections
import collections.abc
from typing import Set
def get_nutrition_information(text):
return "arugula"
def get_aliases(text):
if text == 'rocket':
return ['arugula']
class AliasedIngredients(collections.abc.Set):
def __init__(self, ingredients: set[str]):
self.ingredients = ingredients
def __contains__(self, value: str):
return value in self.ingredients or any(alias in self.ingredients for alias in get_aliases(value))
def __iter__(self):
return iter(self.ingredients)
def __len__(self):
return len(self.ingredients)
ingredients = AliasedIngredients({'arugula', 'eggplant', 'pepper'})
assert ingredients == {'arugula', 'eggplant', 'pepper'}
assert len(ingredients) == 3
assert 'arugula' in ingredients
assert 'rocket' in ingredients
Expected Behavior
Actual Behavior
Your Environment
- Mypy version used: mypy 1.5.1 (compiled: no)
- Mypy command-line flags: unknown
- Mypy configuration options from
mypy.ini(and other config files):unknown - Python version used:3.8.18
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Reproduce el informe con los archivos mencionados graph.py y abc.py ejecutando mypy graph.py. Empieza siguiendo cómo mypy gestiona el archivo abc.py definido por el usuario junto con el módulo de biblioteca abc y su diagnóstico de sombreado de módulos. El trabajo debería considerarse terminado cuando se haya establecido el comportamiento previsto para este caso reproducible y el diagnóstico notificado se haya corregido o resuelto claramente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- devtools
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100