Skip to content

fix: import the submodules these two files use - #57

Merged
cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:fix/import-submodules-explicitly
Sep 13, 2026
Merged

fix: import the submodules these two files use#57
cigamit merged 1 commit into
ctrliq:mainfrom
blaipr:fix/import-submodules-explicitly

Conversation

@blaipr

@blaipr blaipr commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Two places reach a submodule through its parent package without importing it:

import requests
...
class Token_Auth(requests.auth.AuthBase):
import yaml
...
raise yaml.constructor.ConstructorError

Both work today, and only because requests and yaml happen to import those submodules themselves as part of their own initialisation. Nothing in the language guarantees that: import requests binds the package, not its children, and a release that stops importing auth eagerly turns this into an AttributeError at class definition time, which is to say at import of ascenderkit.

Imported by name instead, which is what the code means and what a reader would expect:

from requests.auth import AuthBase
from yaml.constructor import ConstructorError

This also clears the two possibly-missing-submodule warnings the type checker reports, which is how it surfaced.

Note for whoever merges: #25 and #26 also edit api/client.py, so whichever lands after them needs a rebase.

Verified with black --check, flake8 and the unit suite, 355 passing.

@ciq-it-service-account

ciq-it-service-account commented Sep 12, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Two places reach a submodule through its parent package without importing it:

```python
import requests
...
class Token_Auth(requests.auth.AuthBase):
```

```python
import yaml
...
raise yaml.constructor.ConstructorError
```

Both work today, and only because `requests` and `yaml` happen to import those submodules themselves as part of their own initialisation. Nothing in the language guarantees that: `import requests` binds the package, not its children, and a release that stops importing `auth` eagerly turns this into an `AttributeError` at class definition time, which is to say at import of `ascenderkit`.

Imported by name instead, which is what the code means and what a reader would expect:

```python
from requests.auth import AuthBase
from yaml.constructor import ConstructorError
```

This also clears the two `possibly-missing-submodule` warnings the type checker reports, which is how it surfaced.

Note for whoever merges: ctrliq#25 and ctrliq#26 also edit `api/client.py`, so whichever lands after them needs a rebase.

Verified with `black --check`, `flake8` and the unit suite, 355 passing.
@blaipr
blaipr force-pushed the fix/import-submodules-explicitly branch from 7656a8a to 68accef Compare September 13, 2026 09:03
@cigamit cigamit self-assigned this Sep 13, 2026
@cigamit cigamit added the bug Something isn't working label Sep 13, 2026
@cigamit
cigamit merged commit f693f29 into ctrliq:main Sep 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

3 participants