Revisit relationship between Distribution and PathDistribution
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
Direção de pesquisa
Comece lendo as classes Distribution e PathDistribution e os métodos mencionados na issue: at(), metadata(), entry_points(), files(), requires(), read_text() e locate_file(). Revise a discussão da pull request vinculada para conhecer o contexto original. Para considerar o trabalho concluído, seria necessário um design acordado para separar o comportamento específico das subclasses e uma implementação que preserve a funcionalidade relevante da distribuição.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Should
Distributionobjects expose a method to resolve paths?
Yes, that is one solution. There is already .locate_file() which is not far off, except that its implementation in PathDistribution precisely removes the metadata directory that we need in this case.
More generally, I wonder if there is just a tad too much coupling between the Distribution and PathDistribution classes?
There is a mix of abstract and concrete methods in the Distribution base class, and several of the concrete methods seem fairly tightly bound to the PathDistribution subclass. For example, the at() static method creates and returns a PathDistribution instance outright, and the metadata(), entry_points(), files(), and requires() methods are all implemented with assumptions as to which files should be available and that the organization should resemble a dist-info or egg-info distribution.
Now, there is (AFAICS) only the one (PathDistribution) subclass of Distribution available in this project, and I don't really have enough experience with this project or its users to really imagine what other Distribution subclasses would or could exist in the wild.
Still, I would suspect that a subclass that was sufficiently different from PathDistribution to rather prefer subclassing Distribution directly, would then find itself not merely implementing the read_text() an locate_file() abstract methods, but would probably also need to _re_implement several of metadata(), entry_points(), files(), or requires() as well.
Hence, I would raise the question whether some of these methods would be better off with their concrete implementations moved into the PathDistribution subclass? (Of course leaving abstract methods behind in Distribution where that makes sense.) This would grant these concrete methods direct access to the stuff they need inside PathDistribution, instead of having to add more interfaces to Distribution for stuff that really only makes sense for PathDistribution.
Still, this is a much bigger refactoring than I set out to do, and I would not feel comfortable starting this without consulting you.
Originally posted by @jherland in https://github.com/python/importlib_metadata/pull/437#discussion_r1141220985
- Linguagem predominante
- Python
- Estrelas
- 142
- Forks
- 97
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python/importlib_metadata
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
python/importlib_metadata#535 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
python/importlib_metadata#528 · 4 comentários ·
-
documentation help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
python/importlib_metadata#526 · 6 comentários ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
python/importlib_metadata#525 · 2 comentários ·
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
python/importlib_metadata#540 · 1 comentário ·
Todas as issues de python/importlib_metadata
Issues semelhantes
-
货币战争手改优先级配置缺少列表元素类型校验(P3) Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
syfoud/Simulated_Scepter#172 ·
-
A cancelled tests run makes the coverage comment workflow fail and reports it as a red check on main Abertaarea: ci bug perceived difficulty: 3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Nitjsefnie-Harness-Commons/daedalus#921 · 1 comentário ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
EleutherAI/lm-evaluation-harness#4207 ·
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 92/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
ClickHouse/clickhouse-connect#1057 ·