GitNexus/gitnexus/test/fixtures/python-scope-integration/services/auth.py
copilot-swe-agent[bot] f5862070cd
test(python): integration-style scope-resolution tests + suffixResolve fallback
Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/db76e937-4b0e-4c4d-82b1-265a1fb3673d

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
2026-04-19 07:16:02 +00:00

33 lines
1 KiB
Python

"""Auth service — exercises named imports, aliased imports, function-local imports."""
from models.user import User as UserModel
from utils.logger import log_info, log_error
import models.user
class AuthService:
"""Authenticates users."""
def __init__(self):
self.attempts = 0
def authenticate(self, user: UserModel, token: str) -> bool:
self.attempts += 1
log_info("auth attempt")
if not token:
# Function-local import — should attach to the function scope,
# not the module. Tests `pythonImportOwningScope`.
from utils.logger import log_error as fail
fail("no token")
return False
return True
@classmethod
def from_env(cls, env: dict) -> "AuthService":
# @classmethod → cls receiver synthesized as `AuthService`.
return cls()
@staticmethod
def hash_token(token: str) -> str:
# @staticmethod → no implicit receiver; calls inside should NOT
# carry a `self` typeBinding.
return token.upper()