Comments (10)
@mikucz Excellent! Mind writing up a PR as well? Should be a good first contribution, don't you think? :)
@EmilStenstrom PR as requested: #499 :)
from django-components.
@thacoon I wasn't able to get the same error in my project, but it might be because there I'm on django_components 0.66 and mypy 1.7.0. What versions are you on?
Could you possibly test the solution below to check if it solves the issue? In your python packages folder, navigate to django_components/components.py
, and on line 22 or 23, change
from django_components.component_registry import AlreadyRegistered, ComponentRegistry, NotRegistered, register # NOQA
to
from django_components.component_registry import (
AlreadyRegistered as AlreadyRegistered,
ComponentRegistry as ComponentRegistry,
NotRegistered as NotRegistered,
register as register,
)
And then run mypy.
Aliasing at import should make mypy happy
from django-components.
@mikucz Thanks again for the contribution! This has now been release as part of https://github.com/EmilStenstrom/django-components/releases/tag/0.75
from django-components.
@thacoon How would we fix this, and are you open to writing a PR?
from django-components.
Looking at this thread, I guess a temporary workaround could be to either:
- Use
from django_components.component_registry import registry
- Set in mypy.ini
implicit_reexport = True
What would be a proper fix? @thacoon can you share your mypy config?
from django-components.
@JuroOravec my latest configuration is:
[mypy]
# Mypy configuration:
# https://mypy.readthedocs.io/en/latest/config_file.html
enable_error_code =
truthy-bool,
truthy-iterable,
redundant-expr,
unused-awaitable,
ignore-without-code,
possibly-undefined,
redundant-self,
explicit_package_bases = true
ignore_missing_imports = true
strict = true
warn_unreachable = true
plugins =
mypy_django_plugin.main
[mypy-server.apps.*.migrations.*]
# Django migrations should not produce any errors:
ignore_errors = true
[mypy.plugins.django-stubs]
# Docs: https://github.com/typeddjango/django-stubs
django_settings_module = config.settings
strict_settings = false
from django-components.
I think the problem this mypy error is trying to point us at, is that we rely on the component module importing register
as an API, but it's all implicit. So if we would refactor the module, and accidentally remove that import, we wouldn't notice that the API broke.
A simple way to explicitly define the public API is specifying all, and list all the symbols we export. Isn't that the simplest solution here?
from django-components.
@EmilStenstrom So we want to define __all__
inside src/__init__.py
src/component.py
, is that correct?
from django-components.
@thacoon I wasn't able to get the same error in my project, but it might be because there I'm on django_components 0.66 and mypy 1.7.0. What versions are you on?
Could you possibly test the solution below to check if it solves the issue? In your python packages folder, navigate to
django_components/components.py
, and on line 22 or 23, changefrom django_components.component_registry import AlreadyRegistered, ComponentRegistry, NotRegistered, register # NOQAto
from django_components.component_registry import ( AlreadyRegistered as AlreadyRegistered, ComponentRegistry as ComponentRegistry, NotRegistered as NotRegistered, register as register, )And then run mypy.
I can confirm that this works with:
mypy==1.7.1
django_components==0.74
from django-components.
@mikucz Excellent! Mind writing up a PR as well? Should be a good first contribution, don't you think? :)
from django-components.
Related Issues (20)
- Remove requirement for APP_DIRS=False and adding the cached template loader? HOT 1
- Auto-merge dependabot PRs? HOT 2
- Doc table of contents links not working
- JS and CSS not loading HOT 2
- Global context not available when rendering via view methods with RequestContext HOT 5
- Auto-reload server when saving component file
- Allow dynamic slots and fills HOT 1
- Template caching isn't working HOT 1
- Allow different apps to have different settings HOT 1
- Invalid block tag ... 'component'. Did you forget to register or load this tag? error HOT 20
- Warnings (probably errors) when building documentation HOT 3
- Allow dynamic components HOT 5
- feat: React-like render functions (or functional components) and CachedTemplate HOT 3
- Use variables in JS / CSS and caching thereof HOT 15
- Release 0.93 did not trigger documentation build HOT 6
- Hook into the render process to allow to modify the rendered content HOT 1
- RequestContext not populated with context processors on async request HOT 4
- First class support for HTML fragments HOT 9
- Support for AlpineJS in slots HOT 3
- Broken link in documentation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-components.