Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE | Imports in doc's examples #60

Open
v1a0 opened this issue Feb 28, 2022 · 0 comments
Open

ISSUE | Imports in doc's examples #60

v1a0 opened this issue Feb 28, 2022 · 0 comments
Labels
discussion Questions about implementation details, help or support docs Documentation additions or mistakes reports help wanted Extra attention is needed

Comments

@v1a0
Copy link
Owner

v1a0 commented Feb 28, 2022

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

@v1a0 v1a0 added bug Something isn't working or doesn't seems to work right discussion Questions about implementation details, help or support docs Documentation additions or mistakes reports help wanted Extra attention is needed and removed bug Something isn't working or doesn't seems to work right labels Feb 28, 2022
v1a0 added a commit that referenced this issue Mar 31, 2022
- Docs update (issue #60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Questions about implementation details, help or support docs Documentation additions or mistakes reports help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant