fix(types): resolucion integral de tipado estatico, Pyright 0 errores y bump a v3.8.1

This commit is contained in:
2026-10-19 16:34:32 -03:00
parent eb3d71d20d
commit 8b4b478744
20 changed files with 138 additions and 84 deletions
+15 -8
View File
@@ -3,9 +3,9 @@ import os
# Asegurar codificación UTF-8 en consola de Windows
if hasattr(sys.stdout, 'reconfigure'):
sys.stdout.reconfigure(encoding='utf-8')
getattr(sys.stdout, 'reconfigure')(encoding='utf-8')
if hasattr(sys.stderr, 'reconfigure'):
sys.stderr.reconfigure(encoding='utf-8')
getattr(sys.stderr, 'reconfigure')(encoding='utf-8')
from app import create_app, db
from app import models
@@ -282,13 +282,18 @@ def init_database():
role.description = r_data['description']
role.is_system = r_data['is_system']
if role.name == 'Admin':
if getattr(role, 'name', '') == 'Admin':
admin_role = role
# Sincronizar permisos del rol
for mod in module_ids:
level = r_data['permissions'].get(mod, 'none')
role.set_permission(mod, level)
perms = r_data.get('permissions')
if isinstance(perms, dict):
for mod in module_ids:
level = perms.get(mod, 'none')
role.set_permission(mod, str(level))
else:
for mod in module_ids:
role.set_permission(mod, 'none')
db.session.commit()
print("[OK] Roles y matriz de permisos configurados correctamente.")
@@ -299,7 +304,7 @@ def init_database():
Role.name.in_(['Bedelía', 'Bedel\u00eda', 'BEDELÍA'])
).first()
bedelia_canonical = Role.query.filter_by(name='Bedelia').first()
if bedelia_accented and bedelia_canonical and bedelia_accented.id != bedelia_canonical.id:
if bedelia_accented and bedelia_canonical and getattr(bedelia_accented, 'id') != getattr(bedelia_canonical, 'id'):
affected = User.query.filter_by(role_id=bedelia_accented.id).all()
for u in affected:
u.role_id = bedelia_canonical.id
@@ -424,6 +429,8 @@ def init_database():
print(f" [OK] Usuario {u_info['email']} validado (Rol: {u_info['role_name']}).")
# 5. Inicializar edificios institucionales oficiales
b_central = None
b_virtual = None
if not empty_academic:
print("[*] Verificando edificios institucionales...")
from app.models.building import Building
@@ -485,7 +492,7 @@ def init_database():
from app.models.reservation import Reservation, ReservationStatus
from datetime import datetime, timedelta, date
if Classroom.query.count() == 0 and 'b_central' in locals() and b_central and 'b_virtual' in locals() and b_virtual:
if Classroom.query.count() == 0 and b_central is not None and b_virtual is not None:
print("[*] Generando catalogo de aulas...")
for floor in ['PB', '1', '2', '3']:
for num in range(1, 8):