Skip to content

ISSUE | Imports in doc's examples #60

Description

@v1a0

Some doc's examples (like this) have implicit imports:

from sqllex import *

db = SQLite3x(path=...)

db.create_table(
    'users',
    {
        'id': [INTEGER, PRIMARY_KEY, UNIQUE],
        'name': [TEXT, NOT_NULL, DEFAULT, 'Unknown']
    }
)

It's kind off unclear what is actually importing from package, it can be some classes or constants or functions. And if you use this way in your project it may be confused whch classes and constants is "yours" and whats imported from sqllex. And also namespace collisions.

That's why I decided to change it this way:

import sqllex as sx

db = sx.SQLite3x(path=...)

db.create_table(
    'users',
    {
        'id': [sx.INTEGER, sx.PRIMARY_KEY, sx.UNIQUE],
        'name': [sx.TEXT, sx.NOT_NULL, sx.DEFAULT, 'Unknown']
    }
)

Now if you see sx prefix than it's 100% clear this element is as part of sqllex package.
Yes, code becomes a little bit longer but you see where did the variables come from.

Explicit is better than implicit — PEP20

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionQuestions about implementation details, help or supportdocsDocumentation additions or mistakes reportshelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions