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

Make the import keyword a file wide declaration #612

Conversation

cvchaparro
Copy link
Contributor

@cvchaparro cvchaparro commented Jun 5, 2023

Description

Change the way imports are treated such that we move it to a top-level definition as opposed to treating it as a special root that gets added to every definition and is treated specially during parsing.

Linked Items:

Please include the items resolved by and/or associated with this Pull Request using the following syntax to link them for closure upon completion.
Closes #600
Resolves #582

Type of change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Feature improvement

Feature Additions

Include pertinent changes as a result of adding the new feature.

  • None

Bug Fixes

Include pertinent changes of fixing the bug.

  • I changed the tests package initialization to ensure TemporaryDirectorys are always resolving symlinks on creation (as opposed to just during use as a context manager).

Breaking Changes

Include pertinent changes that qualify as breaking changes. Be sure to include information about the impact to end users and additional information for addressing the break if more than a version transition is necessary for mitigating.

  • The import keyword is now considered it's own definition (against which validations, etc can be written) as opposed to a treating it specially during parsing.

Feature Improvement Changes

Include pertinent changes that are improvements to existing features.

  • None

Checklist:

  • Updated documentation accordingly.
  • My changes generate no new warnings.
  • Have updated new and existing unit tests accordingly.
  • Linked associated items to be closed.
  • Have you bumped the version if there will be a release?

@cvchaparro cvchaparro marked this pull request as draft June 5, 2023 22:07
@cvchaparro cvchaparro self-assigned this Jun 8, 2023
@cvchaparro cvchaparro marked this pull request as ready for review June 8, 2023 18:03
Copy link
Contributor

@Coffee2Bits Coffee2Bits left a comment

Choose a reason for hiding this comment

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

Looks good! Just one question/comment.

python/src/aac/lang/definitions/definition.py Outdated Show resolved Hide resolved
@lizzcondrey lizzcondrey merged commit 31cdac6 into pre-release-v0.2.0 Jun 16, 2023
18 checks passed
@lizzcondrey lizzcondrey deleted the 600-i-want-the-import-keyword-moved-from-definitions-to-a-file-wide-declaration-enhancement branch June 16, 2023 15:23
@Coffee2Bits Coffee2Bits mentioned this pull request Jun 23, 2023
9 tasks
lizzcondrey pushed a commit that referenced this pull request Jun 26, 2023
* I want a `Plugin` root key and schema (#500)

* Add Plugin and PluginCommand to spec.yaml

* Update describe-definition to take a reference

* Make ValidationReference and DefinitionReference actual references

* Spelling

* Improve naming

* Add command group schema and update plugin command schema

* Add a display name to command groups

* Add a display name to commands

* Update the gen-plugin architecture definition

* Update references.py

Clean up, refactor, and fix tests.

* Replace hard-coded string values with constants

* Update material model plugin definition

* Update commandGroup description

* Convert version plugin definition

* Convert validate plugin definition

* Fix goto definition test

* Convert gen_design_doc plugin definition

* Convert active_context plugin definition

* Put common command group definitions in spec.yaml

* Convert gen_gherkin_behaviors plugin definition

* Convert gen_json plugin definition

* Convert gen_protobuf plugin definition

* Convert help_dump plugin definition

* Convert gen_plant_uml plugin definition

* Convert lsp_server plugin definition

* Convert plugin_management plugin definition

* Convert print_spec plugin definition

* Convert rest_api plugin definition

* Convert specifications plugin definition

* Put descriptions on the same line

* Dedup constants that refer to the import root key

* Fix gen-protobuf test and minor cleanup

* More fixes for gen-gherkin-behaviors

* Keep up with spec.yaml changes

* Fix reference tests

* Update validator plugin definitions

* Make plugin definition files consistent

* Update definitions for primitive type checking plugin

* Update validators

Also, make the `when' step of validators read the same.

* Update docs

* Update plugin names in implementation files

* Fix imports

* Fix test file names

* Fix plugin management plugin tests

* Fix gen-design-doc generated output after template engine changes

A while ago we made changes to the template engine that made it so that we
didn't have to do as much spacing management in templates and this plugin never
got updated.

* Fix tests failing as a result of plugin name update

Now that plugin name doesn't necessarily equal the validation name for
validations, we need a way to distinguish between them.

* Rename usage of generate-openapi-spec to gen-openapi-spec

Update the OpenAPI spec generation command name for consistency with other
generation commands.

* Update plugin.yaml

Update the test plugin file to fully exercise plugin generation features.

* Add a few more definition field constants

* Update gen-plugin and tests

* Fix name

* Use updated field

* Put test helpers in another package

* Specify VALIDATION_NAME for each plugin

* Add description for `name' argument

* Add the right command dictionary

* Update clear_directory

* Initial updates to templates to acommodate new plugin format

* Updates gen plugin and tests

Update test with correct number of plugin files.

Move all plugin definition source files to the plugin directory for third-party
plugins.

* Fix things

* Try fixing docstring, again

* Updates to the pipeline

* Test plugin definition file updates

Add the test validation definitions.

Use relative file path on definition source value.

Switch command from description to helpText.

* Ignore D417 warnings in tests/ directory

* Update gen-openapi-spec command name

* Update validator implementation validation

We only need to care about validation implementations that are contributed by
active plugins.

* Update pipeline

* Fix flake8 warnings

* Fix command name

* Just use constructor for validation contributions

* Update validate validator implementation test

* Address the comment for TemporaryTestFile

* Fix parameters

* Fixes to TemporaryTestFile

* Update tests.helpers.io package

Also, since we're already touching these files go ahead and change references
from temporary_test_file to TemporaryTestFile.

* Use validator.optional

* Apply suggestions from code review

* Use an Enum instead of strings for the clean_up option

* Remove workaround for missing validator implementations in tests

* Promote specifications to core aac language (#559)

* initial mods, no testing yet

* removed commented out code

* Add Plugin and PluginCommand to spec.yaml

* Update describe-definition to take a reference

* Make ValidationReference and DefinitionReference actual references

* Spelling

* Improve naming

* Add command group schema and update plugin command schema

* Add a display name to command groups

* Add a display name to commands

* Update the gen-plugin architecture definition

* Update references.py

Clean up, refactor, and fix tests.

* Replace hard-coded string values with constants

* Update material model plugin definition

* Update commandGroup description

* Convert version plugin definition

* Convert validate plugin definition

* Fix goto definition test

* Convert gen_design_doc plugin definition

* Convert active_context plugin definition

* Put common command group definitions in spec.yaml

* Convert gen_gherkin_behaviors plugin definition

* Convert gen_json plugin definition

* Convert gen_protobuf plugin definition

* Convert help_dump plugin definition

* Convert gen_plant_uml plugin definition

* Convert lsp_server plugin definition

* Convert plugin_management plugin definition

* Convert print_spec plugin definition

* Convert rest_api plugin definition

* Convert specifications plugin definition

* Put descriptions on the same line

* Dedup constants that refer to the import root key

* Fix gen-protobuf test and minor cleanup

* More fixes for gen-gherkin-behaviors

* Keep up with spec.yaml changes

* Fix reference tests

* Update validator plugin definitions

* Make plugin definition files consistent

* Update definitions for primitive type checking plugin

* Update validators

Also, make the `when' step of validators read the same.

* Update docs

* Update plugin names in implementation files

* Fix imports

* Fix test file names

* Fix plugin management plugin tests

* Fix gen-design-doc generated output after template engine changes

A while ago we made changes to the template engine that made it so that we
didn't have to do as much spacing management in templates and this plugin never
got updated.

* Fix tests failing as a result of plugin name update

Now that plugin name doesn't necessarily equal the validation name for
validations, we need a way to distinguish between them.

* Rename usage of generate-openapi-spec to gen-openapi-spec

Update the OpenAPI spec generation command name for consistency with other
generation commands.

* Update plugin.yaml

Update the test plugin file to fully exercise plugin generation features.

* Add a few more definition field constants

* Update gen-plugin and tests

* Fix name

* Use updated field

* Put test helpers in another package

* Specify VALIDATION_NAME for each plugin

* Add description for `name' argument

* Add the right command dictionary

* Update clear_directory

* Initial updates to templates to acommodate new plugin format

* Updates gen plugin and tests

Update test with correct number of plugin files.

Move all plugin definition source files to the plugin directory for third-party
plugins.

* Fix things

* Try fixing docstring, again

* Updates to the pipeline

* Test plugin definition file updates

Add the test validation definitions.

Use relative file path on definition source value.

Switch command from description to helpText.

* Ignore D417 warnings in tests/ directory

* Update gen-openapi-spec command name

* Update validator implementation validation

We only need to care about validation implementations that are contributed by
active plugins.

* Update pipeline

* Fix flake8 warnings

* Fix command name

* Just use constructor for validation contributions

* Update validate validator implementation test

* Address the comment for TemporaryTestFile

* Fix parameters

* Fixes to TemporaryTestFile

* Update tests.helpers.io package

Also, since we're already touching these files go ahead and change references
from temporary_test_file to TemporaryTestFile.

* Use validator.optional

* Apply suggestions from code review

* Fix tests after merging

* Rename usages of DEFINITION_NAME_SCHEMA to ROOT_KEY_SCHEMA

* Remove original test_gen_plugin in favor of test_gen_plugin_impl

* Update requirement-related validations

* Fix validators

* Use an Enum instead of strings for the clean_up option

* Remove workaround for missing validator implementations in tests

* Fix test failures

* Simplify

* Clean up

---------

Co-authored-by: Cameron Chaparro <cameron.chaparro@zadentech.com>
Co-authored-by: Cameron Chaparro <cvchaparro@users.noreply.github.com>

* Make the import keyword a file wide declaration (#612)

* Update import root key in spec

* Update parser tests

Fix constant names and use the file name constants to define imports.

* Update gen_plugin tests

* Fix goto definition test

* Update parser handling of imports

* Update document link provider

* Fix the document link provider test

* Formatting

* Make sure we handle multiple import definitions per file

My intuition tells me this would be an antipattern but I think we should handle
that using a linting validator, rather than throwing an error.

* Update imports in models

* Make sure we provide imports list as a field

* Minor doc updates

* Add comments to documentation about imports

* Update docs

* Update spec.yaml with a definition structure for imports

* Update import references in definition files

* Update imports to use the new files field

* Update docstring

* Update README.md

* 615 remove the material plugin (#616)

* removed material plugin

* remove unit test and sample model

* disabled test that relied on material plugin model

* Removed skip test annotation and got the test working.

---------

Co-authored-by: Alex Monnet <alexcmonnet@gmail.com>

* AaC Style Guide (#613)

* Added user documentation on the AaC DSL Style Guide

Co-authored-by: Cameron Chaparro <cvchaparro@users.noreply.github.com>

* Update Core Spec to adhere to the Style Guide (#619)

* Updated the Core Spec to adhere to the AaC Style Guide
* Updated example models to adhere to the AaC Style Guide
* Updated first-party plugins to adhere to the AaC Style Guide

Co-authored-by: Cameron Chaparro <cvchaparro@users.noreply.github.com>

* Version bump

* Update Extension test

* Removed duplication spec consant

* Update dupe spec reference

* Removed unused constant

* Update gen puml yaml to use commands

* Readded nixed file docstring

* Moved genjson to commands

* Added parser error handling in line with the YAML error handling.

* Fixed parser import

---------

Co-authored-by: Cameron Chaparro <cvchaparro@users.noreply.github.com>
Co-authored-by: Cameron Chaparro <cameron.chaparro@zadentech.com>
Co-authored-by: Jondavid Black <36022341+jondavid-black@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants