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

Update test_aliases.py #1658

Closed
wants to merge 1 commit into from
Closed

Update test_aliases.py #1658

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 17, 2023

I have made things!

I created this PR in order to fix the error that caused the tests to not even run.

Related issues

Refs #1627

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain: why does this fix a problem for you?
It is the same thing 🤔

@ghost
Copy link
Author

ghost commented Aug 17, 2023

Can you please explain: why does this fix a problem for you? It is the same thing 🤔

Because there are two identical files nested inside each other, python does not see the files that are necessary for the tests to work and issues the following error:

ERROR collecting django_stubs_ext/tests/test_aliases.py _______________________________________________________________
ImportError while importing test module '/home/shamil/opensource/django-stubs/django_stubs_ext/tests/test_aliases.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
django_stubs_ext/tests/test_aliases.py:3: in <module>
    from django_stubs_ext import ValuesQuerySet
E   ImportError: cannot import name 'ValuesQuerySet' from 'django_stubs_ext' (unknown location)
=============================================================================== short test summary info ===============================================================================
ERROR django_stubs_ext/tests/test_aliases.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================================== 1 error in 0.62s ===================================================================================

And after making this change, it turns out to run tests. And out of the running tests, 46 tests fall due to approximately the same problem)

@ghost
Copy link
Author

ghost commented Aug 17, 2023

Can you please explain: why does this fix a problem for you? It is the same thing 🤔

But when running these tests in docker, the tests pass even without modification, and only 2 tests fail, here they are:

=================================== FAILURES ===================================
___________________________ fields_getter_and_setter ___________________________
/tests/typecheck/contrib/gis/test_fields.yml:6: 
E   pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output: 
E   Actual:
E     Error constructing plugin instance of NewSemanalDjangoPlugin (diff)
E     Traceback (most recent call last):            (diff)
E       File "/usr/local/bin/mypy", line 8, in <module> (diff)
E         sys.exit(console_entry())                 (diff)
E                  ^^^^^^^^^^^^^^^                  (diff)
E       File "/usr/local/lib/python3.11/site-packages/mypy/__main__.py", line 15, in console_entry (diff)
E         main()                                    (diff)
E       File "mypy/main.py", line 95, in main       (diff)
E       File "mypy/main.py", line 174, in run_build (diff)
E       File "mypy/build.py", line 197, in build    (diff)
E       File "mypy/build.py", line 242, in _build   (diff)
E       File "mypy/build.py", line 503, in load_plugins (diff)
E       File "mypy/build.py", line 484, in load_plugins_from_config (diff)
E       File "/mypy_django_plugin/main.py", line 77, in __init__ (diff)
E         self.django_context = DjangoContext(self.plugin_config.django_settings_module) (diff)
E                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)
E       File "/mypy_django_plugin/django/context.py", line 84, in __init__ (diff)
E         apps, settings = initialize_django(self.django_settings_module) (diff)
E                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)
E       File "/mypy_django_plugin/django/context.py", line 68, in initialize_django (diff)
E         apps.populate(settings.INSTALLED_APPS)    (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/apps/registry.py", line 116, in populate (diff)
E         app_config.import_models()                (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/apps/config.py", line 269, in import_models (diff)
E         self.models_module = import_module(models_module_name) (diff)
E                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)
E       File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module (diff)
E     return _bootstrap._gcd_import(name[level:], package, level) (diff)
E                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)
E       File "<frozen importlib._bootstrap>", line 1204, in _gcd_import (diff)
E       File "<frozen importlib._bootstrap>", line 1176, in _find_and_load (diff)
E       File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked (diff)
E       File "<frozen importlib._bootstrap>", line 690, in _load_unlocked (diff)
E       File "<frozen importlib._bootstrap_external>", line 940, in exec_module (diff)
E       File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed (diff)
E       File "/tmp/pytest-mypy-iuskmpnx/myapp/models.py", line 2, in <module> (diff)
E         from django.contrib.gis.db.models.fields import PointField, LineStringField, PolygonField, MultiPointField, MultiLineStringField, MultiPolygonField, GeometryCollectionField (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module> (diff)
E         import django.contrib.gis.db.models.functions  # NOQA (diff)
E         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/functions.py", line 3, in <module> (diff)
E         from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module> (diff)
E         from django.contrib.gis import forms, gdal (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module> (diff)
E         from .fields import (  # NOQA             (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module> (diff)
E         from django.contrib.gis.gdal import GDALException (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module> (diff)
E         from django.contrib.gis.gdal.datasource import DataSource (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/datasource.py", line 40, in <module> (diff)
E         from django.contrib.gis.gdal.driver import Driver (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module> (diff)
E         from django.contrib.gis.gdal.prototypes import ds as vcapi (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module> (diff)
E         from django.contrib.gis.gdal.libgdal import lgdal (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/libgdal.py", line 64, in <module> (diff)
E         raise ImproperlyConfigured(               (diff)
E     django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal3.6.0", "gdal3.5.0", "gdal3.4.0", "gdal3.3.0", "gdal3.2.0", "gdal3.1.0", "gdal3.0.0", "gdal2.4.0", "gdal2.3.0", "gdal2.2.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings. (diff)
E   Expected:
E     main:4: note: Revealed type is "django.contrib.gis.geos.point.Point" (diff)
E     main:6: note: Revealed type is "django.contrib.gis.geos.linestring.LineString" (diff)
E     main:8: note: Revealed type is "django.contrib.gis.geos.polygon.Polygon" (diff)
E     main:10: note: Revealed type is "django.contrib.gis.geos.collections.MultiPoint" (diff)
E     main:12: note: Revealed type is "django.contrib.gis.geos.collections.MultiLineString" (diff)
E     main:14: note: Revealed type is "django.contrib.gis.geos.collections.MultiPolygon" (diff)
E     main:16: note: Revealed type is "django.contrib.gis.geos.collections.GeometryCollection" (diff)
E   Alignment of first line difference:
E     E: main:4: note: Revealed type is "django.contrib.gis.geos.point.Point"
E     A: Error constructing plugin instance of NewSemanalDjangoPlugin
E        ^
_______________ django_contrib_gis_base_model_mixin_inheritance ________________
/tests/typecheck/models/test_inheritance.yml:93: 
E   pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output: 
E   Actual:
E     Error constructing plugin instance of NewSemanalDjangoPlugin (diff)
E     Traceback (most recent call last):            (diff)
E       File "/usr/local/bin/mypy", line 8, in <module> (diff)
E         sys.exit(console_entry())                 (diff)
E                  ^^^^^^^^^^^^^^^                  (diff)
E       File "/usr/local/lib/python3.11/site-packages/mypy/__main__.py", line 15, in console_entry (diff)
E         main()                                    (diff)
E       File "mypy/main.py", line 95, in main       (diff)
E       File "mypy/main.py", line 174, in run_build (diff)
E       File "mypy/build.py", line 197, in build    (diff)
E       File "mypy/build.py", line 242, in _build   (diff)
E       File "mypy/build.py", line 503, in load_plugins (diff)
E       File "mypy/build.py", line 484, in load_plugins_from_config (diff)
E       File "/mypy_django_plugin/main.py", line 77, in __init__ (diff)
E         self.django_context = DjangoContext(self.plugin_config.django_settings_module) (diff)
E                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)
E       File "/mypy_django_plugin/django/context.py", line 84, in __init__ (diff)
E         apps, settings = initialize_django(self.django_settings_module) (diff)
E                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)
E       File "/mypy_django_plugin/django/context.py", line 68, in initialize_django (diff)
E         apps.populate(settings.INSTALLED_APPS)    (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/apps/registry.py", line 116, in populate (diff)
E         app_config.import_models()                (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/apps/config.py", line 269, in import_models (diff)
E         self.models_module = import_module(models_module_name) (diff)
E                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)
E       File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module (diff)
E     return _bootstrap._gcd_import(name[level:], package, level) (diff)
E                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)
E       File "<frozen importlib._bootstrap>", line 1204, in _gcd_import (diff)
E       File "<frozen importlib._bootstrap>", line 1176, in _find_and_load (diff)
E       File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked (diff)
E       File "<frozen importlib._bootstrap>", line 690, in _load_unlocked (diff)
E       File "<frozen importlib._bootstrap_external>", line 940, in exec_module (diff)
E       File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed (diff)
E       File "/tmp/pytest-mypy-y5c0f2r6/myapp/models.py", line 2, in <module> (diff)
E         from django.contrib.gis.db import models as gis_models (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module> (diff)
E         import django.contrib.gis.db.models.functions  # NOQA (diff)
E         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/functions.py", line 3, in <module> (diff)
E         from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module> (diff)
E         from django.contrib.gis import forms, gdal (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module> (diff)
E         from .fields import (  # NOQA             (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module> (diff)
E         from django.contrib.gis.gdal import GDALException (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module> (diff)
E         from django.contrib.gis.gdal.datasource import DataSource (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/datasource.py", line 40, in <module> (diff)
E         from django.contrib.gis.gdal.driver import Driver (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module> (diff)
E         from django.contrib.gis.gdal.prototypes import ds as vcapi (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module> (diff)
E         from django.contrib.gis.gdal.libgdal import lgdal (diff)
E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/libgdal.py", line 64, in <module> (diff)
E         raise ImproperlyConfigured(               (diff)
E     django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal3.6.0", "gdal3.5.0", "gdal3.4.0", "gdal3.3.0", "gdal3.2.0", "gdal3.1.0", "gdal3.0.0", "gdal2.4.0", "gdal2.3.0", "gdal2.2.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings. (diff)
E   Expected:
E     main:2: note: Revealed type is "builtins.str" (diff)
E     main:3: note: Revealed type is "datetime.datetime" (diff)
E   Alignment of first line difference:
E     E: main:2: note: Revealed type is "builtins.str"
E     A: Error constructing plugin instance of NewSemanalDjangoPlugin
E        ^
=========================== short test summary info ============================
FAILED tests/typecheck/contrib/gis/test_fields.yml::fields_getter_and_setter
FAILED tests/typecheck/models/test_inheritance.yml::django_contrib_gis_base_model_mixin_inheritance
================== 2 failed, 381 passed in 579.71s (0:09:39) ===================

@flaeppe
Copy link
Member

flaeppe commented Aug 17, 2023

Can you please explain: why does this fix a problem for you? It is the same thing 🤔

Because there are two identical files nested inside each other, python does not see the files that are necessary for the tests to work and issues the following error:


ERROR collecting django_stubs_ext/tests/test_aliases.py _______________________________________________________________

ImportError while importing test module '/home/shamil/opensource/django-stubs/django_stubs_ext/tests/test_aliases.py'.

Hint: make sure your test modules/packages have valid Python names.

Traceback:

/usr/lib/python3.11/importlib/__init__.py:126: in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

django_stubs_ext/tests/test_aliases.py:3: in <module>

    from django_stubs_ext import ValuesQuerySet

E   ImportError: cannot import name 'ValuesQuerySet' from 'django_stubs_ext' (unknown location)

=============================================================================== short test summary info ===============================================================================

ERROR django_stubs_ext/tests/test_aliases.py

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

================================================================================== 1 error in 0.62s ===================================================================================

And after making this change, it turns out to run tests. And out of the running tests, 46 tests fall due to approximately the same problem)

I think this rather occurs due to a name collision. Since django_stubs_ext is installed via pip and booting python in the root of this project, there's a django_stubs_ext directory. Which seems to take precedence.

An example fix if django_stubs_ext was stand alone would be to rename the django_stubs_ext to src. But any name change to avoid the collision is probably a fix

@flaeppe
Copy link
Member

flaeppe commented Aug 17, 2023

Can you please explain: why does this fix a problem for you? It is the same thing 🤔

But when running these tests in docker, the tests pass even without modification, and only 2 tests fail, here they are:


=================================== FAILURES ===================================

___________________________ fields_getter_and_setter ___________________________

/tests/typecheck/contrib/gis/test_fields.yml:6: 

E   pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output: 

E   Actual:

E     Error constructing plugin instance of NewSemanalDjangoPlugin (diff)

E     Traceback (most recent call last):            (diff)

E       File "/usr/local/bin/mypy", line 8, in <module> (diff)

E         sys.exit(console_entry())                 (diff)

E                  ^^^^^^^^^^^^^^^                  (diff)

E       File "/usr/local/lib/python3.11/site-packages/mypy/__main__.py", line 15, in console_entry (diff)

E         main()                                    (diff)

E       File "mypy/main.py", line 95, in main       (diff)

E       File "mypy/main.py", line 174, in run_build (diff)

E       File "mypy/build.py", line 197, in build    (diff)

E       File "mypy/build.py", line 242, in _build   (diff)

E       File "mypy/build.py", line 503, in load_plugins (diff)

E       File "mypy/build.py", line 484, in load_plugins_from_config (diff)

E       File "/mypy_django_plugin/main.py", line 77, in __init__ (diff)

E         self.django_context = DjangoContext(self.plugin_config.django_settings_module) (diff)

E                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)

E       File "/mypy_django_plugin/django/context.py", line 84, in __init__ (diff)

E         apps, settings = initialize_django(self.django_settings_module) (diff)

E                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)

E       File "/mypy_django_plugin/django/context.py", line 68, in initialize_django (diff)

E         apps.populate(settings.INSTALLED_APPS)    (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/apps/registry.py", line 116, in populate (diff)

E         app_config.import_models()                (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/apps/config.py", line 269, in import_models (diff)

E         self.models_module = import_module(models_module_name) (diff)

E                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)

E       File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module (diff)

E     return _bootstrap._gcd_import(name[level:], package, level) (diff)

E                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)

E       File "<frozen importlib._bootstrap>", line 1204, in _gcd_import (diff)

E       File "<frozen importlib._bootstrap>", line 1176, in _find_and_load (diff)

E       File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked (diff)

E       File "<frozen importlib._bootstrap>", line 690, in _load_unlocked (diff)

E       File "<frozen importlib._bootstrap_external>", line 940, in exec_module (diff)

E       File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed (diff)

E       File "/tmp/pytest-mypy-iuskmpnx/myapp/models.py", line 2, in <module> (diff)

E         from django.contrib.gis.db.models.fields import PointField, LineStringField, PolygonField, MultiPointField, MultiLineStringField, MultiPolygonField, GeometryCollectionField (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module> (diff)

E         import django.contrib.gis.db.models.functions  # NOQA (diff)

E         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/functions.py", line 3, in <module> (diff)

E         from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module> (diff)

E         from django.contrib.gis import forms, gdal (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module> (diff)

E         from .fields import (  # NOQA             (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module> (diff)

E         from django.contrib.gis.gdal import GDALException (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module> (diff)

E         from django.contrib.gis.gdal.datasource import DataSource (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/datasource.py", line 40, in <module> (diff)

E         from django.contrib.gis.gdal.driver import Driver (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module> (diff)

E         from django.contrib.gis.gdal.prototypes import ds as vcapi (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module> (diff)

E         from django.contrib.gis.gdal.libgdal import lgdal (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/libgdal.py", line 64, in <module> (diff)

E         raise ImproperlyConfigured(               (diff)

E     django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal3.6.0", "gdal3.5.0", "gdal3.4.0", "gdal3.3.0", "gdal3.2.0", "gdal3.1.0", "gdal3.0.0", "gdal2.4.0", "gdal2.3.0", "gdal2.2.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings. (diff)

E   Expected:

E     main:4: note: Revealed type is "django.contrib.gis.geos.point.Point" (diff)

E     main:6: note: Revealed type is "django.contrib.gis.geos.linestring.LineString" (diff)

E     main:8: note: Revealed type is "django.contrib.gis.geos.polygon.Polygon" (diff)

E     main:10: note: Revealed type is "django.contrib.gis.geos.collections.MultiPoint" (diff)

E     main:12: note: Revealed type is "django.contrib.gis.geos.collections.MultiLineString" (diff)

E     main:14: note: Revealed type is "django.contrib.gis.geos.collections.MultiPolygon" (diff)

E     main:16: note: Revealed type is "django.contrib.gis.geos.collections.GeometryCollection" (diff)

E   Alignment of first line difference:

E     E: main:4: note: Revealed type is "django.contrib.gis.geos.point.Point"

E     A: Error constructing plugin instance of NewSemanalDjangoPlugin

E        ^

_______________ django_contrib_gis_base_model_mixin_inheritance ________________

/tests/typecheck/models/test_inheritance.yml:93: 

E   pytest_mypy_plugins.utils.TypecheckAssertionError: Invalid output: 

E   Actual:

E     Error constructing plugin instance of NewSemanalDjangoPlugin (diff)

E     Traceback (most recent call last):            (diff)

E       File "/usr/local/bin/mypy", line 8, in <module> (diff)

E         sys.exit(console_entry())                 (diff)

E                  ^^^^^^^^^^^^^^^                  (diff)

E       File "/usr/local/lib/python3.11/site-packages/mypy/__main__.py", line 15, in console_entry (diff)

E         main()                                    (diff)

E       File "mypy/main.py", line 95, in main       (diff)

E       File "mypy/main.py", line 174, in run_build (diff)

E       File "mypy/build.py", line 197, in build    (diff)

E       File "mypy/build.py", line 242, in _build   (diff)

E       File "mypy/build.py", line 503, in load_plugins (diff)

E       File "mypy/build.py", line 484, in load_plugins_from_config (diff)

E       File "/mypy_django_plugin/main.py", line 77, in __init__ (diff)

E         self.django_context = DjangoContext(self.plugin_config.django_settings_module) (diff)

E                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)

E       File "/mypy_django_plugin/django/context.py", line 84, in __init__ (diff)

E         apps, settings = initialize_django(self.django_settings_module) (diff)

E                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)

E       File "/mypy_django_plugin/django/context.py", line 68, in initialize_django (diff)

E         apps.populate(settings.INSTALLED_APPS)    (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/apps/registry.py", line 116, in populate (diff)

E         app_config.import_models()                (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/apps/config.py", line 269, in import_models (diff)

E         self.models_module = import_module(models_module_name) (diff)

E                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)

E       File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module (diff)

E     return _bootstrap._gcd_import(name[level:], package, level) (diff)

E                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)

E       File "<frozen importlib._bootstrap>", line 1204, in _gcd_import (diff)

E       File "<frozen importlib._bootstrap>", line 1176, in _find_and_load (diff)

E       File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked (diff)

E       File "<frozen importlib._bootstrap>", line 690, in _load_unlocked (diff)

E       File "<frozen importlib._bootstrap_external>", line 940, in exec_module (diff)

E       File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed (diff)

E       File "/tmp/pytest-mypy-y5c0f2r6/myapp/models.py", line 2, in <module> (diff)

E         from django.contrib.gis.db import models as gis_models (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module> (diff)

E         import django.contrib.gis.db.models.functions  # NOQA (diff)

E         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/functions.py", line 3, in <module> (diff)

E         from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module> (diff)

E         from django.contrib.gis import forms, gdal (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module> (diff)

E         from .fields import (  # NOQA             (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module> (diff)

E         from django.contrib.gis.gdal import GDALException (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module> (diff)

E         from django.contrib.gis.gdal.datasource import DataSource (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/datasource.py", line 40, in <module> (diff)

E         from django.contrib.gis.gdal.driver import Driver (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module> (diff)

E         from django.contrib.gis.gdal.prototypes import ds as vcapi (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module> (diff)

E         from django.contrib.gis.gdal.libgdal import lgdal (diff)

E       File "/usr/local/lib/python3.11/site-packages/django/contrib/gis/gdal/libgdal.py", line 64, in <module> (diff)

E         raise ImproperlyConfigured(               (diff)

E     django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal3.6.0", "gdal3.5.0", "gdal3.4.0", "gdal3.3.0", "gdal3.2.0", "gdal3.1.0", "gdal3.0.0", "gdal2.4.0", "gdal2.3.0", "gdal2.2.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings. (diff)

E   Expected:

E     main:2: note: Revealed type is "builtins.str" (diff)

E     main:3: note: Revealed type is "datetime.datetime" (diff)

E   Alignment of first line difference:

E     E: main:2: note: Revealed type is "builtins.str"

E     A: Error constructing plugin instance of NewSemanalDjangoPlugin

E        ^

=========================== short test summary info ============================

FAILED tests/typecheck/contrib/gis/test_fields.yml::fields_getter_and_setter

FAILED tests/typecheck/models/test_inheritance.yml::django_contrib_gis_base_model_mixin_inheritance

================== 2 failed, 381 passed in 579.71s (0:09:39) ===================



These errors are due to missing postgis related packages

@ghost
Copy link
Author

ghost commented Aug 17, 2023

Yes, I agree with you, it may be a folder naming problem. But what surprises me is that in each OS the results of running tests with changes are different (

@flaeppe
Copy link
Member

flaeppe commented Aug 31, 2023

#1667 have now changed the directory name for django_stubs_ext

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants