Skip to content

feat: Temporarily negate ProjectAuthenticationWarning when using Project.is_shared()#610

Open
Boss-1s wants to merge 2 commits intoTimMcCool:mainfrom
Boss-1s:chore
Open

feat: Temporarily negate ProjectAuthenticationWarning when using Project.is_shared()#610
Boss-1s wants to merge 2 commits intoTimMcCool:mainfrom
Boss-1s:chore

Conversation

@Boss-1s
Copy link
Copy Markdown
Contributor

@Boss-1s Boss-1s commented May 9, 2026

Solves issue #592

Changes

  • Negated Project.get_project's ProjectAuthenticationWarning using warnings.catch_warnings()

Tests

Tested in CPython 3.12.1 REPL

Python 3.12.1 (main, Mar 11 2026, 12:17:56) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Ctrl click to launch VS Code Native REPL
>>> import scratchattach
>>> print(scratchattach.Project(id=103).is_shared())
False
>>> print(scratchattach.Project(id=104).is_shared())
True
>>> print(scratchattach.get_project(103))
/workspaces/scratchattach/src/scratchattach/scratchattach/site/project.py:828: ProjectAuthenticationWarning: For methods that require authentication, use session.connect_project instead of get_project.
If you want to remove this warning, use `warnings.filterwarnings('ignore', category=scratchattach.ProjectAuthenticationWarning)`.
To ignore all warnings of the type GetAuthenticationWarning, which includes this warning, use `warnings.filterwarnings('ignore', category=scratchattach.GetAuthenticationWarning)`.
  warnings.warn(
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/workspaces/scratchattach/src/scratchattach/scratchattach/site/project.py", line 836, in get_project
    return commons._get_object("id", project_id, Project, exceptions.ProjectNotFound)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/scratchattach/src/scratchattach/scratchattach/utils/commons.py", line 163, in _get_object
    raise e
  File "/workspaces/scratchattach/src/scratchattach/scratchattach/utils/commons.py", line 157, in _get_object
    raise NotFoundException
scratchattach.utils.exceptions.ProjectNotFound
>>> print(scratchattach.Project(id=104).is_shared())
True
>>> print(scratchattach.get_project(104))
/workspaces/scratchattach/src/scratchattach/scratchattach/site/project.py:828: ProjectAuthenticationWarning: For methods that require authentication, use session.connect_project instead of get_project.
If you want to remove this warning, use `warnings.filterwarnings('ignore', category=scratchattach.ProjectAuthenticationWarning)`.
To ignore all warnings of the type GetAuthenticationWarning, which includes this warning, use `warnings.filterwarnings('ignore', category=scratchattach.GetAuthenticationWarning)`.
  warnings.warn(
-P 104 (Weekend)
>>> exit()

Boss-1s added 2 commits May 8, 2026 21:59
Signed-off-by: Boss_1s <95505913+Boss-1s@users.noreply.github.com>
Signed-off-by: Boss_1s <95505913+Boss-1s@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant