Skip to content

Conversation

@xiangyan99
Copy link
Member

No description provided.

@xiangyan99 xiangyan99 requested a review from kristapratico May 19, 2021 19:32

@classmethod
def create_from_file(cls, name, file_path):
f = open(file_path, "r")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might make sense to open the file in a context manager so the file gets closed

def create_from_file(cls, name, file_path):
f = open(file_path, "r")
solr_format_synonyms = f.read()
synonyms = solr_format_synonyms.split("\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to use splitlines() instead? I think split("\n") will include a trailing newline in the file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. If there is a trailing newline in the file, we will have an empty synonym.

This is by design and we have same behavior in https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/search/azure-search-documents/azure/search/documents/indexes/models/_models.py#L460

@xiangyan99 xiangyan99 merged commit f283843 into master May 19, 2021
@xiangyan99 xiangyan99 deleted the search_create_synonym_map_from_file branch May 19, 2021 20:52
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-python that referenced this pull request May 6, 2022
[App Configuration] Promote 2022-05-01 stable version (Azure#18811)

* Add 2022-05-01 folder based on 2021-10-01-preview

* Update 2022-05-01 folder

* Fix readme issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants