Skip to content

Refactor Streamlit Navigation: Cleaner Code & Admin/User Handling #324

@itspavant

Description

@itspavant

Important Points to Note

  • I agree to adhere to the project's Code of Conduct.
  • I have reviewed and understood the project's Contributing Guidelines.
  • I have checked the existing issues and can confirm that this is not a duplicate.
  • I have reviewed and understood the project's Issue Creation Guidelines.

Category

Code Refactoring

Enhancement Description

📌 Description

The current application() function for navigation in app.py works but can be improved in terms of:

  • Code readability and maintainability
  • Proper error handling (e.g., secrets lookup, missing attributes in st.user)
  • Best practices (docstrings, avoiding deep nesting, adding __main__ guard)

✅ Proposed Changes

  • Refactor application() for better readability (use variables for user/admin checks).
  • Add docstrings and inline comments to explain logic.
  • Use .get() for secrets lookup to avoid KeyError.
  • Add if __name__ == "__main__": guard for safe script execution.
  • Ensure PEP8 formatting and consistent indentation.

🚀 Benefits

  • Cleaner, more maintainable code.
  • Safer execution in different environments.
  • Easier for new contributors (especially GSSoC’25 participants) to understand the navigation logic.

🔖 Labels

gssoc25 enhancement refactor

Screenshots or Logs

Image

This complete code can be improved as stated above, I am not sure if I am allowed to fork and implement changes as it is stated not to raise a PR before I am assigned to the issue.

Priority

Up to 2 days

Open Source Program

GSSoC

Would you like to work on this issue?

Yes

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions