Skip to content

Commit b6bb973

Browse files
committed
Don't introduce the new griffelib namespace
1 parent 2814aa7 commit b6bb973

67 files changed

Lines changed: 344 additions & 370 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config/ruff.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ignore = [
3535
"TRY003", # Avoid specifying long messages outside the exception class
3636
]
3737

38-
logger-objects = ["griffe.logger", "griffelib.logger"]
38+
logger-objects = ["griffe.logger", "griffe.logger"]
3939

4040
[lint.per-file-ignores]
4141
"packages/griffecli/src/griffecli/__main__.py" = [
@@ -44,18 +44,18 @@ logger-objects = ["griffe.logger", "griffelib.logger"]
4444
"packages/griffecli/src/griffecli/_internal/cli.py" = [
4545
"T201", # Print statement
4646
]
47-
"packages/griffelib/src/griffelib/_internal/git.py" = [
47+
"packages/griffelib/src/griffe/_internal/git.py" = [
4848
"S603", # `subprocess` call: check for execution of untrusted input
4949
"S607", # Starting a process with a partial executable path
5050
]
51-
"packages/griffelib/src/griffelib/_internal/agents/nodes/*.py" = [
51+
"packages/griffelib/src/griffe/_internal/agents/nodes/*.py" = [
5252
"ARG001", # Unused function argument
5353
"N812", # Lowercase `keyword` imported as non-lowercase `NodeKeyword`
5454
]
55-
"packages/griffelib/src/griffelib/_internal/debug.py" = [
55+
"packages/griffelib/src/griffe/_internal/debug.py" = [
5656
"T201", # Print statement
5757
]
58-
"packages/griffelib/src/griffelib/_internal/**.py" = [
58+
"packages/griffelib/src/griffe/_internal/**.py" = [
5959
"D100", # Missing docstring in public module
6060
]
6161
"scripts/*.py" = [
@@ -84,7 +84,7 @@ docstring-quotes = "double"
8484
ban-relative-imports = "all"
8585

8686
[lint.isort]
87-
known-first-party = ["griffe", "griffelib", "griffecli"]
87+
known-first-party = ["griffe", "griffecli"]
8888

8989
[lint.pydocstyle]
9090
convention = "google"

docs/extensions/official/runtime-objects.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This extension stores runtime objects corresponding to each loaded Griffe object
1515
>>> griffe_data["parse"].extra
1616
defaultdict(<class 'dict'>, {'runtime-objects': {'object': <function parse at 0x78685c951260>}})
1717
>>> griffe_data["Module"].extra
18-
defaultdict(<class 'dict'>, {'runtime-objects': {'object': <class 'griffelib._internal.models.Module'>}})
18+
defaultdict(<class 'dict'>, {'runtime-objects': {'object': <class 'griffe._internal.models.Module'>}})
1919
```
2020

2121
It can be useful in combination with mkdocstrings-python and custom templates, to iterate over object values or their attributes that couldn't be loaded by Griffe itself (for example, objects built dynamically and loaded as attributes won't have "members" to iterate over).

docs/guide/contributors/architecture.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ descriptions = {
2323
"site": "Documentation site, built with `make run mkdocs build` (git-ignored).",
2424
"src": "The source of our Python package(s). See [Sources](#sources) and [Program structure](#program-structure).",
2525
"src/griffe": "Our public API, exposed to users. See [Program structure](#program-structure).",
26-
"packages/griffelib/src/griffelib/_internal": "Our internal API, hidden from users. See [Program structure](#program-structure).",
26+
"packages/griffelib/src/griffe/_internal": "Our internal API, hidden from users. See [Program structure](#program-structure).",
2727
"tests": "Our test suite. See [Tests](#tests).",
2828
".copier-answers.yml": "The answers file generated by [Copier](https://copier.readthedocs.io/en/stable/). See [Boilerplate](#boilerplate).",
2929
"devdeps.txt": "Our development dependencies specification. See [`make setup`][command-setup] command.",
@@ -104,11 +104,11 @@ Sources are located in the `src` folder, following the [src-layout](https://pack
104104

105105
Our test suite is located in the `tests` folder. It is located outside of the sources as to not pollute distributions (it would be very wrong to publish a `tests` package as part of our distributions, since this name is extremely common), or worse, the public API. The `tests` folder is however included in our source distributions (`.tar.gz`), alongside most of our metadata and configuration files. Check out `pyproject.toml` to get the full list of files included in our source distributions.
106106

107-
The test suite is based on [pytest](https://docs.pytest.org/en/8.2.x/). Test modules reflect our internal API structure, and except for a few test modules that test specific aspects of our API, each test module tests the logic from the corresponding module in the internal API. For example, `test_finder.py` tests code of the `griffelib._internal.finder` internal module, while `test_functions` tests our ability to extract correct information from function signatures, statically. The general rule of thumb when writing new tests is to mirror the internal API. If a test touches to many aspects of the loading process, it can be added to the `test_loader` test module.
107+
The test suite is based on [pytest](https://docs.pytest.org/en/8.2.x/). Test modules reflect our internal API structure, and except for a few test modules that test specific aspects of our API, each test module tests the logic from the corresponding module in the internal API. For example, `test_finder.py` tests code of the `griffe._internal.finder` internal module, while `test_functions` tests our ability to extract correct information from function signatures, statically. The general rule of thumb when writing new tests is to mirror the internal API. If a test touches to many aspects of the loading process, it can be added to the `test_loader` test module.
108108

109109
## Program structure
110110

111-
The internal API is contained within the `packages/griffelib/src/griffelib/_internal` folder. The top-level `griffe/__init__.py` module exposes all the public API, by importing the internal objects from `griffelib`, which itself imports from various submodules of `griffelib._internal`.
111+
The internal API is contained within the `packages/griffelib/src/griffe/_internal` folder. The top-level `griffe/__init__.py` module exposes all the public API, by importing the internal objects from various submodules of `griffe._internal`.
112112

113113
Users then import `griffe` directly, or import objects from it.
114114

@@ -122,7 +122,7 @@ if os.getenv("DEPLOY") == "true":
122122
from pydeps.target import Target
123123

124124
cli.verbose = cli._not_verbose
125-
options = cli.parse_args(["packages/griffelib/src/griffelib", "--noshow", "--reverse"])
125+
options = cli.parse_args(["packages/griffelib/src/griffe", "--noshow", "--reverse"])
126126
colors.START_COLOR = 128
127127
target = Target(options["fname"])
128128
with target.chdir_work():

docs/guide/users/loading.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ from package1 import X
214214
False
215215
>>> package2["X"].target
216216
Traceback (most recent call last):
217-
File "griffelib/_internal/models.py", line 1375, in _resolve_target
217+
File "griffe/_internal/models.py", line 1375, in _resolve_target
218218
resolved = self.modules_collection.get_member(self.target_path)
219219
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
220-
File "griffelib/_internal/mixins.py", line 84, in get_member
220+
File "griffe/_internal/mixins.py", line 84, in get_member
221221
return self.members[parts[0]].get_member(parts[1:]) # type: ignore[attr-defined]
222222
~~~~~~~~~~~~^^^^^^^^^^
223223
KeyError: 'package1'
@@ -226,13 +226,13 @@ The above exception was the direct cause of the following exception:
226226

227227
Traceback (most recent call last):
228228
File "<stdin>", line 1, in <module>
229-
File "griffelib/_internal/dataclasses.py", line 1310, in target
229+
File "griffe/_internal/dataclasses.py", line 1310, in target
230230
self.resolve_target()
231-
File "griffelib/_internal/dataclasses.py", line 1369, in resolve_target
231+
File "griffe/_internal/dataclasses.py", line 1369, in resolve_target
232232
self._resolve_target()
233-
File "griffelib/_internal/dataclasses.py", line 1377, in _resolve_target
233+
File "griffe/_internal/dataclasses.py", line 1377, in _resolve_target
234234
raise AliasResolutionError(self) from error
235-
griffelib._internal.exceptions.AliasResolutionError: Could not resolve alias package2.X pointing at package1.X (in package2/__init__.py:1)
235+
griffe._internal.exceptions.AliasResolutionError: Could not resolve alias package2.X pointing at package1.X (in package2/__init__.py:1)
236236
```
237237

238238
As you can see in the interpreter session above, Griffe did not resolve the `X` alias. When we tried to access its target object anyway, it failed with a `KeyError`, which was raised again as an [`AliasResolutionError`][griffe.AliasResolutionError].
@@ -250,7 +250,7 @@ False # Hmm?
250250
>>> package2["X"].target
251251
Traceback (most recent call last):
252252
...
253-
griffelib._internal.exceptions.AliasResolutionError: Could not resolve alias package2.X pointing at package1.X (in package2/__init__.py:1)
253+
griffe._internal.exceptions.AliasResolutionError: Could not resolve alias package2.X pointing at package1.X (in package2/__init__.py:1)
254254
```
255255

256256
The same exception again? What happened here? We loaded both packages, but Griffe still failed to resolve the alias. That is expected; here is the explanation.

docs/guide/users/navigating.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ When [loading an object](loading.md), Griffe will give you back an instance of o
1414
```python
1515
>>> import griffe
1616
>>> type(griffe.load("markdown"))
17-
<class 'griffelib._internal.models.Module'>
17+
<class 'griffe._internal.models.Module'>
1818
>>> type(griffe.load("markdown.core.Markdown"))
19-
<class 'griffelib._internal.models.Class'>
19+
<class 'griffe._internal.models.Class'>
2020
>>> type(griffe.load("markdown.Markdown"))
21-
<class 'griffelib._internal.models.Alias'>
21+
<class 'griffe._internal.models.Alias'>
2222
>>> type(griffe.load("markdown.core.markdown"))
23-
<class 'griffelib._internal.models.Function'>
23+
<class 'griffe._internal.models.Function'>
2424
>>> type(griffe.load("markdown.markdown"))
25-
<class 'griffelib._internal.models.Alias'>
25+
<class 'griffe._internal.models.Alias'>
2626
>>> type(griffe.load("markdown.Markdown.references"))
27-
<class 'griffelib._internal.models.Attribute'>
27+
<class 'griffe._internal.models.Attribute'>
2828
```
2929

3030
However deep the object is, Griffe loads the entire package. It means that in all the cases above, Griffe loaded the whole `markdown` package. The model instance Griffe gives you back is therefore part of a tree that you can navigate.
@@ -41,7 +41,7 @@ To access an object's members, there are a few options:
4141

4242
```pycon
4343
>>> import griffe
44-
>>> markdown = griffelib.load("markdown")
44+
>>> markdown = griffe.load("markdown")
4545
>>> markdown.members["Markdown"]
4646
Alias('Markdown', 'markdown.core.Markdown')
4747
>>> markdown.members["core"].members["Markdown"]
@@ -54,7 +54,7 @@ To access an object's members, there are a few options:
5454

5555
```pycon
5656
>>> import griffe
57-
>>> markdown = griffelib.load("markdown")
57+
>>> markdown = griffe.load("markdown")
5858
>>> markdown["core"]["Markdown"] # chained access
5959
Class('Markdown', 46, 451)
6060
>>> markdown["core.Markdown"] # merged access
@@ -65,7 +65,7 @@ To access an object's members, there are a few options:
6565

6666
```pycon
6767
>>> import griffe
68-
>>> markdown = griffelib.load("markdown")
68+
>>> markdown = griffe.load("markdown")
6969
>>> markdown[("core", "Markdown")] # tuple access
7070
Class('Markdown', 46, 451)
7171
>>> # Due to the nature of the subscript syntax,
@@ -78,7 +78,7 @@ To access an object's members, there are a few options:
7878

7979
```pycon
8080
>>> import griffe
81-
>>> markdown = griffelib.load("markdown")
81+
>>> markdown = griffe.load("markdown")
8282
>>> markdown.get_member("core.Markdown")
8383
Class('Markdown', 46, 451)
8484
```
@@ -122,7 +122,7 @@ If a base class cannot be resolved during computation of inherited members, Grif
122122

123123
If you want to access all members at once (both declared and inherited), use the [`all_members`][griffe.Object.all_members] attribute. If you want to access only declared members, use the [`members`][griffe.Object] attribute.
124124

125-
Accessing the [`attributes`][griffe.Object.attributes], [`functions`][griffe.Object.functions], [`classes`][griffe.Object.classes], [`type_aliases`][griffe.Object.type_aliases] or [`modules`][griffe.Object.modules] attributes will trigger inheritance computation, so make sure to only access them once everything is loaded by griffelib. Don't try to access inherited members in extensions, while visiting or inspecting modules.
125+
Accessing the [`attributes`][griffe.Object.attributes], [`functions`][griffe.Object.functions], [`classes`][griffe.Object.classes], [`type_aliases`][griffe.Object.type_aliases] or [`modules`][griffe.Object.modules] attributes will trigger inheritance computation, so make sure to only access them once everything is loaded by griffe. Don't try to access inherited members in extensions, while visiting or inspecting modules.
126126

127127
#### Limitations
128128

@@ -254,7 +254,7 @@ from pkg2 import A as B
254254

255255
```pycon
256256
>>> import griffe
257-
>>> B = griffelib.load("pkg1.B")
257+
>>> B = griffe.load("pkg1.B")
258258
>>> B.path
259259
'pkg1.B'
260260
>>> B.canonical_path
@@ -339,13 +339,13 @@ Each object has an optional [`docstring`][griffe.Object.docstring] attached to i
339339

340340
Docstrings can be parsed against several [docstring-styles](../../reference/docstrings.md), which are micro-formats that allow documenting things such as parameters, returned values, raised exceptions, etc..
341341

342-
When loading a package, it is possible to specify the docstring style to attach to every docstring (see the `docstring_parser` parameter of [`griffelib.load`][griffe.load]). Accessing the [`parsed`][griffe.Docstring.parsed] field of a docstring will use this style to parse the docstring and return a list of [docstring sections][advanced-api-sections]. Each section has a `value` whose shape depends on the section kind. For example, parameter sections have a list of parameter representations as value, while a text section only has a string as value.
342+
When loading a package, it is possible to specify the docstring style to attach to every docstring (see the `docstring_parser` parameter of [`griffe.load`][griffe.load]). Accessing the [`parsed`][griffe.Docstring.parsed] field of a docstring will use this style to parse the docstring and return a list of [docstring sections][advanced-api-sections]. Each section has a `value` whose shape depends on the section kind. For example, parameter sections have a list of parameter representations as value, while a text section only has a string as value.
343343

344344
After a package is loaded, it is still possible to change the style used for specific docstrings by either overriding their [`parser`][griffe.Docstring.parser] and [`parser_options`][griffe.Docstring.parser_options] attributes, or by calling their [`parse()`][griffe.Docstring.parse] method with a different style:
345345

346346
```pycon
347347
>>> import griffe
348-
>>> markdown = griffelib.load("markdown", docstring_parser="google")
348+
>>> markdown = griffe.load("markdown", docstring_parser="google")
349349
>>> markdown["Markdown"].docstring.parse("numpy")
350350
[...]
351351
```

docs/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ Both commands accept a `-h`, `--help` argument to show all the available options
2222

2323
## Python library
2424

25-
As a library, Griffe exposes all its public API directly in the top-level module. It means you can simply import `griffe` or `griffelib` to access all its API.
25+
As a library, Griffe exposes all its public API directly in the top-level module. It means you can simply import `griffe` to access all its API.
2626

2727
```python
28-
import griffe # or griffelib
28+
import griffe
2929

3030
griffe.load(...)
3131
griffe.find_breaking_changes(...)

docs/reference/api/agents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Griffe is able to analyze code both statically and dynamically.
44

55
## **Main API**
66

7-
::: griffelib.visit
7+
::: griffe.visit
88

99
::: griffe.inspect
1010

docs/reference/api/expressions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Expressions
22

3-
::: griffelib._internal.expressions
3+
::: griffe._internal.expressions
44
options:
55
members: false
66
show_root_heading: false

docs/reference/api/loaders.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
## **Main API**
44

5-
::: griffelib.load
5+
::: griffe.load
66

7-
::: griffelib.load_git
7+
::: griffe.load_git
88

9-
::: griffelib.load_pypi
9+
::: griffe.load_pypi
1010

1111
## **Advanced API**
1212

13-
::: griffelib.GriffeLoader
13+
::: griffe.GriffeLoader
1414

15-
::: griffelib.ModulesCollection
15+
::: griffe.ModulesCollection
1616

17-
::: griffelib.LinesCollection
17+
::: griffe.LinesCollection
1818

1919
## **Additional API**
2020

21-
::: griffelib.Stats
21+
::: griffe.Stats
2222

23-
::: griffelib.merge_stubs
23+
::: griffe.merge_stubs

duties.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def check_api(ctx: Context, *cli_args: str) -> None:
285285
*cli_args: Additional Griffe CLI arguments.
286286
"""
287287
ctx.run(
288-
tools.griffecli.check(
288+
tools.griffe.check(
289289
"griffe",
290290
search=["src"],
291291
color=True,

0 commit comments

Comments
 (0)