Project attributes are now read accessible

This commit is contained in:
Dave Halter
2020-08-01 18:26:26 +02:00
parent 9d1587a41d
commit 2f7d0ec42c
3 changed files with 30 additions and 1 deletions

View File

@@ -16,6 +16,7 @@ Unreleased
- Functions with ``@property`` now return ``property`` instead of ``function`` - Functions with ``@property`` now return ``property`` instead of ``function``
in ``Name().type`` in ``Name().type``
- Started using annotations - Started using annotations
- Project attributes are now read accessible
This is likely going to be the last minor release before 1.0. This is likely going to be the last minor release before 1.0.

View File

@@ -152,6 +152,29 @@ class Project:
""" """
return self._path return self._path
@property
def sys_path(self):
"""
The sys path provided to this project. This can be None and in that
case will be auto generated.
"""
return self._sys_path
@property
def smart_sys_path(self):
"""
If the sys path is going to be calculated in a smart way, where
additional paths are added.
"""
return self._smart_sys_path
@property
def load_unsafe_extensions(self):
"""
Wheter the project loads unsafe extensions.
"""
return self._load_unsafe_extensions
@inference_state_as_method_param_cache() @inference_state_as_method_param_cache()
def _get_base_sys_path(self, inference_state): def _get_base_sys_path(self, inference_state):
# The sys path has not been set explicitly. # The sys path has not been set explicitly.

View File

@@ -17,7 +17,12 @@ def test_django_default_project(Script):
) )
c, = script.complete() c, = script.complete()
assert c.name == "SomeModel" assert c.name == "SomeModel"
assert script._inference_state.project._django is True
project = script._inference_state.project
assert project._django is True
assert project.sys_path is None
assert project.smart_sys_path is True
assert project.load_unsafe_extensions is False
def test_django_default_project_of_file(Script): def test_django_default_project_of_file(Script):