
GITHUB . COM {
}
Detected CMS Systems:
- Wordpress (2 occurrences)
Title:
`Package` should not be a `Module`/`File` Β· Issue #11137 Β· pytest-dev/pytest
Description:
Note: this issue is extracted verbatim from #7777 (comment) so I can refer to it separately Package is currently a subclass of a Module, with package.path being the __init__.py file. While technically in terms of the Python data model th...
Website Age:
17 years and 8 months (reg. 2007-10-09).
Matching Content Categories {π}
- Shopping
- Video & Online Content
- Social Networks
Content Management System {π}
What CMS is github.com built with?
Github.com operates using WORDPRESS.
Traffic Estimate {π}
What is the average monthly size of github.com audience?
ππ Tremendous Traffic: 10M - 20M visitors per month
Based on our best estimate, this website will receive around 10,000,019 visitors per month in the current month.
However, some sources were not loaded, we suggest to reload the page to get complete results.
check SE Ranking
check Ahrefs
check Similarweb
check Ubersuggest
check Semrush
How Does Github.com Make Money? {πΈ}
Subscription Packages {π³}
We've located a dedicated page on github.com that might include details about subscription plans or recurring payments. We identified it based on the word pricing in one of its internal links. Below, you'll find additional estimates for its monthly recurring revenues.How Much Does Github.com Make? {π°}
Subscription Packages {π³}
Prices on github.com are in US Dollars ($).
They range from $4.00/month to $21.00/month.
We estimate that the site has approximately 4,989,889 paying customers.
The estimated monthly recurring revenue (MRR) is $20,957,532.
The estimated annual recurring revenues (ARR) are $251,490,385.
Wordpress Themes and Plugins {π¨}
What WordPress theme does this site use?
It is strange but we were not able to detect any theme on the page.
What WordPress plugins does this website use?
It is strange but we were not able to detect any plugins on the page.
Keywords {π}
package, initpy, module, file, bluetech, doesnt, modulefile, issue, pytest, python, longer, change, type, directory, collection, mentioned, sign, issues, path, lines, added, proposal, feature, backward, compatibility, projects, closed, collects, datadogddtracepy, skip, navigation, code, pull, requests, actions, security, comment, packagepath, terms, act, call, nodesfile, points, breaks, real, nonpackage, pythonfiles, glob, packages, paths,
Topics {βοΈ}
pytest/src/_pytest/cacheprovider pytest/src/_pytest/main pytest/src/_pytest/python 72457dc bluetech mentioned a21fb87 bluetech closed py module setup/teardown backward compatibility issues bluetech mentioned collection phase type code dealing ad-hoc manner collecting pkg/__init__ type projects python data model registers teardown_module finalizer personal information `package` package collection work set[path] = set py importing part projects milestone 8 support pytest 8 changelog type terms package directory collector pytest backward compatibility feature type pkg issues c811fe5 python bfca39d python collection related teardown_module conflict py file py necessitates package = package py collects separately package makes package breaking package entire package package scope extracted verbatim pretty convinced wrong decision special-casings file requested discussed previously setup_module function match unittest
Payment Methods {π}
- Braintree
Questions {β}
- Already have an account?
- How should package collection work?
Schema {πΊοΈ}
DiscussionForumPosting:
context:https://schema.org
headline:`Package` should not be a `Module`/`File`
articleBody:*Note: this issue is extracted verbatim from https://github.com/pytest-dev/pytest/issues/7777#issuecomment-1575652688 so I can refer to it separately*
`Package` is currently a subclass of a `Module`, with `package.path` being the `__init__.py` file.
While technically in terms of the Python data model this [is correct](https://docs.python.org/3/glossary.html#term-package), I'm pretty convinced this was the wrong decision in pytest:
`Package` is a `Module` with path `__init__.py`, but it doesn't actually act as a `Module` behaviorally, it overrides everything that `Module` does and doesn't call `super()` on anything.
`Module` is a `nodes.File`, which makes `Package` a `nodes.File`, but it doesn't act as a file.
The previous points can be rephrased as: `Package` breaks Liskov substitution -- any code dealing with `File` or `Module` generically probably doesn't want `Package`.
`Package` is a `Module` with path `__init__.py`, but it actually collects a "real" (non-`Package`) `Module` for the `__init__.py` file (if permitted by `python_files` glob). This is very confusing.
`Package` and `__init__.py` necessitates several special-casings because of these points:
- https://github.com/pytest-dev/pytest/blob/24534cdd29d74e302e86db1a719c99e024d7903e/src/_pytest/cacheprovider.py#L275-L278
- https://github.com/pytest-dev/pytest/blob/24534cdd29d74e302e86db1a719c99e024d7903e/src/_pytest/main.py#L805-L818
- https://github.com/pytest-dev/pytest/blob/24534cdd29d74e302e86db1a719c99e024d7903e/src/_pytest/fixtures.py#L123
- https://github.com/pytest-dev/pytest/blob/24534cdd29d74e302e86db1a719c99e024d7903e/src/_pytest/python.py#L229-L231
- https://github.com/pytest-dev/pytest/blob/24534cdd29d74e302e86db1a719c99e024d7903e/src/_pytest/python.py#L750-L761
### Proposed solution
As part of the breaking `Package` changes discussed previously in this issue, also make these changes
- `Package` no longer inherits from `Module` (or `File` by extension), just from `FSCollector`.
- `Package.path` is the package directory, not the `__init__.py` file.
- Collecting `pkg/__init__.py` collects the `__init__.py` file as a module (file), doesn't collect the entire package.
This also matches the new `Directory` node, which is the non-`Package` directory collector. `Directory` will inherit just from `FSCollector` and its `path` will be the directory. It will be much better if they are as similar to each other as possible.
### Complication
Currently `Package` has a `setup()` method which imports the `__init__.py`' and runs its `setup_module` function and registers `teardown_module` finalizer (in effectively the package scope). If we want to stop having `Package` as a `Module` it becomes a bit less natural to implement.
This functionality has some issues:
- It is undocumented.
- It doesn't match `unittest` which doesn't have package functionality
- The names `setup_module` and `teardown_module` conflict with the "real" `__init__.py` `Module` setup/teardown; i.e., these methods are executed twice, if the `__init__.py` is included in the glob. It would have been better to call them `setup_package`/`teardown_package` (this is how nose [calls them](https://nose.readthedocs.io/en/latest/writing_tests.html#test-packages)).
It is tempting to just remove it, but it will probably cause some breakage (particularly the `__init__.py` importing part), so for now I plan to keep it in an ad-hoc manner.
### POC
I have an initial implementation of this change here, with all tests passing:
https://github.com/bluetech/pytest/commits/pkg-mod
author:
url:https://github.com/bluetech
type:Person
name:bluetech
datePublished:2023-06-24T16:23:10.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:0
url:https://github.com/11137/pytest/issues/11137
context:https://schema.org
headline:`Package` should not be a `Module`/`File`
articleBody:*Note: this issue is extracted verbatim from https://github.com/pytest-dev/pytest/issues/7777#issuecomment-1575652688 so I can refer to it separately*
`Package` is currently a subclass of a `Module`, with `package.path` being the `__init__.py` file.
While technically in terms of the Python data model this [is correct](https://docs.python.org/3/glossary.html#term-package), I'm pretty convinced this was the wrong decision in pytest:
`Package` is a `Module` with path `__init__.py`, but it doesn't actually act as a `Module` behaviorally, it overrides everything that `Module` does and doesn't call `super()` on anything.
`Module` is a `nodes.File`, which makes `Package` a `nodes.File`, but it doesn't act as a file.
The previous points can be rephrased as: `Package` breaks Liskov substitution -- any code dealing with `File` or `Module` generically probably doesn't want `Package`.
`Package` is a `Module` with path `__init__.py`, but it actually collects a "real" (non-`Package`) `Module` for the `__init__.py` file (if permitted by `python_files` glob). This is very confusing.
`Package` and `__init__.py` necessitates several special-casings because of these points:
- https://github.com/pytest-dev/pytest/blob/24534cdd29d74e302e86db1a719c99e024d7903e/src/_pytest/cacheprovider.py#L275-L278
- https://github.com/pytest-dev/pytest/blob/24534cdd29d74e302e86db1a719c99e024d7903e/src/_pytest/main.py#L805-L818
- https://github.com/pytest-dev/pytest/blob/24534cdd29d74e302e86db1a719c99e024d7903e/src/_pytest/fixtures.py#L123
- https://github.com/pytest-dev/pytest/blob/24534cdd29d74e302e86db1a719c99e024d7903e/src/_pytest/python.py#L229-L231
- https://github.com/pytest-dev/pytest/blob/24534cdd29d74e302e86db1a719c99e024d7903e/src/_pytest/python.py#L750-L761
### Proposed solution
As part of the breaking `Package` changes discussed previously in this issue, also make these changes
- `Package` no longer inherits from `Module` (or `File` by extension), just from `FSCollector`.
- `Package.path` is the package directory, not the `__init__.py` file.
- Collecting `pkg/__init__.py` collects the `__init__.py` file as a module (file), doesn't collect the entire package.
This also matches the new `Directory` node, which is the non-`Package` directory collector. `Directory` will inherit just from `FSCollector` and its `path` will be the directory. It will be much better if they are as similar to each other as possible.
### Complication
Currently `Package` has a `setup()` method which imports the `__init__.py`' and runs its `setup_module` function and registers `teardown_module` finalizer (in effectively the package scope). If we want to stop having `Package` as a `Module` it becomes a bit less natural to implement.
This functionality has some issues:
- It is undocumented.
- It doesn't match `unittest` which doesn't have package functionality
- The names `setup_module` and `teardown_module` conflict with the "real" `__init__.py` `Module` setup/teardown; i.e., these methods are executed twice, if the `__init__.py` is included in the glob. It would have been better to call them `setup_package`/`teardown_package` (this is how nose [calls them](https://nose.readthedocs.io/en/latest/writing_tests.html#test-packages)).
It is tempting to just remove it, but it will probably cause some breakage (particularly the `__init__.py` importing part), so for now I plan to keep it in an ad-hoc manner.
### POC
I have an initial implementation of this change here, with all tests passing:
https://github.com/bluetech/pytest/commits/pkg-mod
author:
url:https://github.com/bluetech
type:Person
name:bluetech
datePublished:2023-06-24T16:23:10.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:0
url:https://github.com/11137/pytest/issues/11137
Person:
url:https://github.com/bluetech
name:bluetech
url:https://github.com/bluetech
name:bluetech
InteractionCounter:
interactionType:https://schema.org/CommentAction
userInteractionCount:0
interactionType:https://schema.org/CommentAction
userInteractionCount:0
External Links {π}(4)
- How much profit is https://github.blog making per month?
- How much profit does https://docs.python.org/3/glossary.html#term-package make?
- What are the total earnings of https://nose.readthedocs.io/en/latest/writing_tests.html#test-packages?
- How much does https://www.githubstatus.com/ pull in monthly?
Analytics and Tracking {π}
- Site Verification - Google
Libraries {π}
- Clipboard.js
- D3.js
- Lodash
Emails and Hosting {βοΈ}
Mail Servers:
- aspmx.l.google.com
- alt1.aspmx.l.google.com
- alt2.aspmx.l.google.com
- alt3.aspmx.l.google.com
- alt4.aspmx.l.google.com
Name Servers:
- dns1.p08.nsone.net
- dns2.p08.nsone.net
- dns3.p08.nsone.net
- dns4.p08.nsone.net
- ns-1283.awsdns-32.org
- ns-1707.awsdns-21.co.uk
- ns-421.awsdns-52.com
- ns-520.awsdns-01.net